尝试为我网站上的用户编写更改用户名。问题是,当我尝试更改用户名时,它只是将我的用户从数据库中删除。
<?php
$captcha = 'xb33ssa1';
function gen_token($pass, $salt) {
$salt = strtolower($salt);
$str = hash("sha512", $pass.$salt);
$len = strlen($salt);
return strtoupper(substr($str, $len, 17));
}
$username = $_SESSION['username'];
$current = $_POST['currentpassword'];
$newuser = $_POST['newusername'];
$veriuser = $_POST['verifyusername'];
$current = stripslashes($current);
$newuser= stripslashes($newuser);
$veriuser = stripslashes($veriuser);
$current = mysql_real_escape_string($current);
$newuser = mysql_real_escape_string($newuser);
$veriuser = mysql_real_escape_string($veriuser);
$current = gen_token($current, $username);
$newuser = gen_token($newuser, $username);
$veriuser = gen_token($veriuser, $username);
if(isset($_POST['currentpassword']) || isset($_POST['newusername']) || isset($_POST['verifyusername'])) {
if($_POST['newusername']==$_POST['verifyusername']) {
if(!empty($_POST['currentpassword']) || !empty($_POST['newusername']) || !empty($_POST['verifyusername'])) {
if($veriuser==$newuser) {
$con = mysql_query("SELECT * from meh_users WHERE Password='$current' && Username='$username'");
$count = mysql_num_rows($con);
if($count>0) {
if($_POST['captcha']==$captcha) {
$status = '<center>You have successfully changed your username!</center>';
$boxkind = 'success';
mysql_query("UPDATE meh_users SET Username='$newuser' WHERE Username='$username'");
} else {
$status = '<center>The captcha you entered does not match on the given captcha!</center>';
$boxkind = 'danger';
}
} else {
$status = '<center>The password you entered does not match on the password you currently have.</center>';
$boxkind = 'danger';
}
} else {
$status = '<center>The username you entered for your new and the verification of the new username does not match.</center>';
$boxkind = 'danger';
}
} else {
$status = '<center>Some fields remains empty, please fill every field, for they are all important.</center>';
$boxkind = 'danger';
}
} else {
$status = '<center>The password you entered for your new and the verification of the new password does not match.</center>';
$boxkind = 'danger';
}
} else {
$status = '<center>Please fill in the prerequisites below. Please be notified that you can not retrieve your Username once you have forgotten your new one.</center>';
$boxkind = 'info';
}
?>
<!-- BEGIN PAGE HEADER-->
<div class="row">
<div class="col-md-12">
<!-- BEGIN PAGE TITLE & BREADCRUMB-->
<h3 class="page-title">
Change Username <small></small>
</h3>
<ul class="page-breadcrumb breadcrumb">
<li>
<i class="icon-home"></i>
Account Manager
<i class="icon-angle-right"></i>
</li>
<li>Change Username</li>
</ul>
<!-- END PAGE TITLE & BREADCRUMB-->
</div>
</div>
<!-- END PAGE HEADER-->
<!-- END DASHBOARD STATS -->
<div class="tab-content">
<div class="tab-pane active" id="tab_0">
<div class="portlet box green">
<div class="portlet-title">
<div class="caption"><i class="icon-reorder"></i> Change your Username:</div>
</div>
</div>
<div class="alert alert-<?php echo $boxkind; ?> alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
<?php echo $status; ?>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form action="../vipdailyreward" method="POST" class="form-horizontal">
<div class="form-body">
<div class="form-group">
<label class="col-md-3 control-label">Current Password</label>
<div class="col-md-4">
<div class="input-group">
<input type="password" class="form-control" placeholder="Current Password" name="currentpassword">
<span class="input-group-addon"><i class="icon-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">New Username</label>
<div class="col-md-4">
<div class="input-group">
<input type="text" class="form-control" placeholder="New Username" name="newusername">
<span class="input-group-addon"><i class="icon-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Verify Username</label>
<div class="col-md-4">
<div class="input-group">
<input type="text" class="form-control" placeholder="Verify Username" name="verifyusername">
<span class="input-group-addon"><i class="icon-user"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Captcha:</label>
<div class="col-md-4">
<div class="input-group">
<input type="text" class="form-control" placeholder="Type: <?php echo $captcha; ?>" name="captcha">
</div><br />
</div>
</div>
</div>
<div class="form-actions fluid">
<div class="col-md-offset-3 col-md-9">
<input type="submit" class="btn blue" name="submit"></input>
<input type="reset" class="btn default" value="Clear"></input>
</div>
</div>
</form>
<!-- END FORM-->
</div>
</div>
</div>