我有一个从员工列表中填充的更新表单。这些值正在传递但未在数据库中更新。这是我的代码以及我显示的已通过。
<?php
$con = mysql_connect("localhost","root","*******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$query = mysql_query("select * from backup");
if(isset($_POST['update']))
$id = $_POST['id'];
$first = $_POST['first'];
$last = $_POST['last'];
$store = $_POST['store'];
$title = $_POST['title'];
$title2 = $_POST['other'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$dept = $_POST['dept'];
$bio = $_POST['bio'];
$query="UPDATE backup SET first='$first', last='$last', store='$store', title='$title', title2='$title2', phone='$phone', email='$email', bio='$bio' WHERE id='$id'";
mysql_query($query);
echo "Record Updated";
mysql_close();
print_r($_POST)
?>
这是结果
Record UpdatedArray ( [id] => 1396 [first] => Charles [last] => Adams [store] => [dept] => Accounting [title] => Accounting Clerk [other] => [phone] => 410 -555-1212[email] => [email2] => [bio] => Charlie 从 2009 年 8 月开始。这是一个测试.... [Submit] => Submit )
有人可以帮我解决我可能做错的事情吗?至于注射,我将在完成测试后修复它。我知道这可能听起来倒退,但我需要先找出为什么这不起作用。
感谢您对此的任何帮助