gpt4 book ai didi

PHP 不执行更新

转载 作者:太空宇宙 更新时间:2023-11-03 11:12:02 24 4
gpt4 key购买 nike

我用用户的名字、姓氏、电子邮件和临时密码创建了一个数据库。当用户第一次登录时,他们会看到一个配置文件,其中包含数据库中已有的信息以及他们必须填写的一些其他字段。单击提交后,表单应该会更新他们在数据库中的配置文件,但事实并非如此.该数据库称为“用户”。有人可以告诉我我做错了什么吗?

 <?php
$testerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters
$tester = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["tester"]); // filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters

include "scripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM users WHERE id='$testerID' AND username='$tester' AND password='$password' LIMIT 1"); // query the person
$row = mysql_fetch_array($sql);
$fname = $row['fname'];
$lname = $row['lname'];
$email = $row['email'];

$existCount = mysql_num_rows($sql); // count the row nums
if ($existCount == 0) { // evaluate the count
echo "Your login session data is not on record in the database.";
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tester Home</title>
</head>

<body>
<table width="886">
<tr>
<td width="876"><h1>Welcome
<?php
echo $fname;
?>
to the Closed Beta</h1></td>
</tr>
</table>
<p>&nbsp;</p>
<div id="content">
<?php
$date = getdate();
// Parse the form data and add inventory item to the system
if (isset($_POST['$new_password'])) {
$new_email = mysql_real_escape_string($_POST['email']);
$new_password = mysql_real_escape_string($_POST['new_password']);
$phone_model = mysql_real_escape_string($_POST['phone_model']);
$carrier = mysql_real_escape_string($_POST['carrier']);

$sql_update = mysql_query("UPDATE users SET email='$new_email', password='$new_password', phone_model='$phone_model', carrier='$carrier' WHERE id='$testerID'");
}
if(is_null($test_start)){
echo "
<form action=\"index.php\" enctype=\"multipart/form-data\" name=\"myForm\" id=\"myform\" method=\"post\">
<table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\">
<tr>
<td width=\"20%\" align=\"right\">ID: </td>
<td width=\"80%\"><label>
$testerID
</label></td>
</tr>
<tr>
<td align=\"right\">Username: </td>
<td><label>
$tester
</label></td>
</tr>
<tr>
<td align=\"right\">First Name: </td>
<td><label>
$fname
</label></td>
</tr>
<tr>
<td align=\"right\">Last Name: </td>
<td><label>
$lname
</label></td>
</tr>
<tr>
<td align=\"right\">Email Address: </td>
<td><label>
<input type=\"text\" name=\"email\" id=\"email\" value=\"\"/>
</label></td>
</tr>
<tr>
<td align=\"right\">Old password: (the one you were assigned)</td>
<td><label>
<input type=\"text\" name=\"old_password\" id=\"old_password\" value=\"$password\"/>
</label></td>
</tr>
<tr>
<td align=\"right\">New Password: </td>
<td><label>
<input type=\"text\" name=\"new_password\" id=\"newPassField\" />
</label></td>
</tr>
<tr>
<td align=\"right\">Confirm New Password: </td>
<td><label>
<input type=\"text\" name=\"confirm_password\" id=\"newPassField\" />
</label></td>
</tr>
<tr>
<td align=\"right\">Phone Model: </td>
<td><label>
<input type=\"text\" name=\"phone_model\" id=\"phone_model\" value=\"$phone_model\"/> (a 4 digit number)
</label></td>
</tr>
<tr>
<td align=\"right\">Carrier: </td>
<td><label>
<input type=\"text\" name=\"carrier\" id=\"carrier\" cols=\"64\" rows=\"5\" value=\"$carrier\"/>
</label></td>
</tr>
<input type=\"submit\" name=\"button\" id=\"button\" value=\"Update\" />
</table>
</form>";
}else{

}
?>
</div>
<p>&nbsp;</p>
</body>
</html>

最佳答案

您有 isset($_POST['$new_password']) 而不是 isset($_POST['new_password'])。注意添加的 $

关于PHP 不执行更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com