我做了一個小網站,非會員可以在網站註冊,當他們註冊他們的詳細資料時應該在數據庫表中進行攪動。我有這個工作,但現在不是,除了將詳細信息存儲在數據庫中,它完成了所有工作。任何人都可以幫忙嗎?會員註冊不起作用
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$repeatpassword=$_POST['repeatpassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = strip_tags($myusername);
$mypassword = strip_tags($mypassword);
$repeatpassword = strip_tags($repeatpassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$repeatpassword = mysql_real_escape_string($repeatpassword);
if($myusername&&$mypassword&&$repeatpassword)
{
if ($mypassword==$repeatpassword)
{
if (strlen($myusername)>10)
{
header("location:erroruname.php");
}
else
{
if (strlen($mypassword)>10||strlen($mypassword)<5)
header("location:errorpword.php");
else
{
$queryreg = mysql_query("
INSERT INTO $tbl_name VALUES('','$myusername','$mypassword')
");
session_register("myusername");
session_register("mypassword");
header("location:insertdetail.php?myusername=" . $username);
}
}
}
else
header("location:errornomatch.php");
}
else
header("location:errorfields.php");
從來沒有存儲密碼以純文本 – 2012-05-28 00:24:17