我是php语言的新手,我试图做一个简单的登录页面,索引页面和注销页面,现在我试图改变登录密码页面,但它不能在mysql中工作,我的编码没有任何错误但在MySQL数据中,它不会更改我更新的php表单中的内容。为什么我不能更新mysql数据库的用户名和密码?
这里是我的代码,
<?php
//including the database connection file
$host="localhost"; // Host name
$username="paapuu_user"; // Mysql username
$password="mn78k1a2"; // Mysql password
$db_name="paapuu"; // Database name
$tbl_name="admin"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if(isset($_POST['update']))
{
//here the id that we post is the same id that we get from url
//id indicates the id of this data which we are editing
//id is unique and a particular id is associated with particular data
$id1 = $_POST['id'];
$username1=$_POST['username'];
$password1=$_POST['password'];
//updating the table
$result=mysql_query("UPDATE admin SET username='$username1', password='$password1' WHERE id=$id1");
echo "<script language='javascript' type='text/javascript'>";
$error1="<p>Update successfully!</p>";
echo "alert($error1); window.location ='viewpassword.php'";
echo "</script>";
}
作为一个纯粹的技术问题,这属于StackOverflow(请不要在此处重新发布,如果有足够的人投票结束,它将被自动化)。 – 2011-04-01 07:25:06
这不是发布这个问题的正确的地方。 – 2011-04-01 07:54:48