Mysql查询清除行而不是更新

时间:2012-12-05 04:20:48

标签: php mysql

我不知道为什么这样做是这样的,我在我的代码中回显了$sqll并显示了所有正确的信息,但当它返回到包含信息的页面时它是空白的。

这是脚本

<?php
include("header.php"); 
include("sidebar.php");

$memberon = $_GET['user'];
$getmember = mysql_query("SELECT * FROM accounts WHERE username='".$memberon."'");
$member = mysql_fetch_array($getmember);
?>       

    <h2>Edit User</h2> 

<?php
$points = asql($_POST['points']);
$cash = asql($_POST['cash']);
$banned = asql($_POST['banned']);
$completed = asql($_POST['completed']);
$confirm= asql($_POST['confirm']);
$referral= asql($_POST['ref']);
$email= asql($_POST['email']);
$username= asql($_POST['username']);
$fname= asql($_POST['fname']);
$lname= asql($_POST['lname']);
$add= asql($_POST['address']);
$state= asql($_POST['state']);
$country= asql($_POST['country']);
$postal= asql($_POST['postal']);
$apt= asql($_POST['suite']);
$city= asql($_POST['city']);
$phone= asql($_POST['phone']);
$dob= asql($_POST['dob']);


if ($_POST['subm']) {
if($points <> $member['points'] || $cash <> $member['current_b']){
$final_report = "Checking";
print"This users balance has been updated, please input your pass code to confirm these changes <br />
<form method='post' action=''><input type='hidden' name='points' value='$points'><input type='hidden' name='cash' value='$cash'><input type='hidden' name='banned' value='$banned'><input type='hidden' name='confirm' value='$confirm'><input type='hidden' name='ref' value='$referral'><input type='hidden' name='email' value='$email'><input type='hidden' name='fname' value='$fname'><input type='hidden' name='lname' value='$lname'><input type='hidden' name='address' value='$add'><input type='hidden' name='state' value='$state'><input type='hidden' name='country' value='$country'><input type='hidden' name='postal' value='$postal'><input type='hidden' name='suite' value='$apt'><input type='hidden' name='city' value='$city'><input type='hidden' name='phone' value='$phone'><input type='hidden' name='dob' value='$dob'><input type='password' name='passcode' /><input type='submit' name='pcheck' value='Sumbit' /></form>";
}
else
{
$final_report = "";
}
if($final_report == NULL){
$updatemembers = mysql_query("UPDATE accounts SET points='$points', current_b='$cash', level='$banned', email_check='$confirm', referral='$referral', username='$username', fname='$fname', lname='$lname', email='$email', address='$add', state='$state', country='$country', postal='$postal', suite='$apt', city='$city', phone='$phone', dob='$dob' WHERE username='".$memberon."'") or die(mysql_error());
     print "You Have Successfully Updated this Information";    
     header("Refresh: 2;url=edit.php?user=".$memberon."");  
}
}

if($_POST['pcheck']){
$pchecki = asql($_POST['passcode']);
$pchecks = md5($pchecki);
$check = mysql_query("SELECT * FROM panel_access WHERE psn = '".$_SESSION['aname']."'") or die(mysql_error());
$checkar = mysql_fetch_array($check);
$final_report = "Checking.";
if($pchecks != $checkar['change_ab']){
$final_report = "That password is incorrect.";
     print "".$final_report.""; 
     header("Refresh: 2;url=edit.php?user=".$memberon."");
}
else
{
$final_report = "";
}
if($final_report == NULL){
$sqll = "UPDATE accounts SET points='".$points."', current_b='".$cash."', level='".$banned."', email_check='".$confirm."', referral='".$referral."', username='".$username."', fname='".$fname."', lname='".$lname."', email='".$email."', address='".$add."', state='".$state."', country='".$country."', postal='".$postal."', suite='".$apt."', city='".$city."', phone='".$phone."', dob='".$dob."' WHERE username='".$memberon."'";
$updatemember = mysql_query($sqll) or die(mysql_error());
     print "You Have Successfully Updated this Information ".$sqll."";  
     header("Refresh: 2;url=edit.php?user=".$memberon."");  
}
}

    if(!isset($_POST['subm']) && !isset($_POST['pcheck']))
    {
 ?>                   
<div class='form'>
         <form action='' method='post'><input type=hidden name=subm value=1>
                <div class="element">
                        <label for='email'>Email:</label>
                        <input type='text' name='email' id='email' value='<?php echo $member['email'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='username'>Username:</label>
                        <input type='text' name='username' id='username' value='<?php echo $member['username'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='ip'>IP Address:</label>
                        <input type='text' name='ip' id='ip' value='<?php echo $member['ip'] ?>' size='54' readonly='readonly' />
                    </div>
                   <div class="element">
                        <label for='banned'>Banned: <font color='red' size='1'><b>1=No 2=Yes</b></font></label>
                        <input type='text' name='banned' id='banned' value='<?php echo $member['level'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='confirm'>E-Mail Confirmed: <font color='red' size='1'>0=No 1=Yes</font></label>
                        <input type='text' name='confirm' id='confirm' value='<?php echo $member['email_check'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='ref'>Referral:</label>
                        <input type='text' name='ref' id='ref' value='<?php echo $member['referral'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='points'>Points:</label>
                        <input type='text' name='points' id='points' value='<?php echo $member['points'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='cash'>Cash:</label>
                        <input type='text' name='cash' id='cash' value='<?php echo $member['current_b'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='fname'>First Name:</label>
                        <input type='text' name='fname' id='fname' value='<?php echo $member['fname'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='lname'>Last Name:</label>
                        <input type='text' name='lname' id='lname' value='<?php echo $member['lname'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='phone'>Phone:</label>
                        <input type='tel' name='phone' id='phone' value='<?php echo $member['phone'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='dob'>Date of Birth:</label>
                        <input type='text' name='dob' id='dob' value='<?php echo $member['dob'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='address'>Address:</label>
                        <input type='text' name='address' id='address' value='<?php echo $member['address'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='suite'>Suite/Apt.:</label>
                        <input type='text' name='suite' id='suite' value='<?php echo $member['suite'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='country'>Country:</label>
                        <input type='text' name='country' id='country' value='<?php echo $member['country'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='state'>State:</label>
                        <input type='text' name='state' id='state' value='<?php echo $member['state'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='city'>City:</label>
                        <input type='text' name='city' id='city' value='<?php echo $member['city'] ?>' size='54' />
                    </div>
                   <div class="element">
                        <label for='postal'>Postal Code:</label>
                        <input type='text' name='postal' id='postal' value='<?php echo $member['postal'] ?>' size='54' />
                    </div>
<?php
                     print"<dl class='submit'>
                    <input type='submit' name='submit' id='submit' value='Submit' />
                     </dl>





         </form>
         </div> "; 
      }
      include("footer.php");
?>

在旁注上我知道mysql_query和喜欢的内容正在被弃用,我想要注意的是我没有写这个,只是为客户做一些编辑,这部分正在发生在后方痛苦。

也是if($_POST['pcheck'])中唯一无效的查询,if($_POST['subm']的第一个查询工作正常

1 个答案:

答案 0 :(得分:0)

首先,最后有一个空字符串。这并没有伤害,但也没有任何意义。

您将页面重定向到edit.php?user=$memberon,但在收到POST请求时未设置$memberon。你可以有GET或POST,但不能两者都有。

我猜,你必须重定向到

edit.php?user=$username