我是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