我目前正在爲我的網站註冊頁面。我只是需要一些幫助,因爲我不確定爲什麼當我輸入註冊詳細信息(只有2個字段)它會轉到謝謝頁面,但是當我檢查我的數據庫時,USERS下沒有新記錄。以下是我的代碼:php註冊頁面將不會註冊用戶
<?php
$host="*********"; // Host name
$username="**********"; // Mysql username
$password="**********"; // Mysql password
$db_name="arihealthinfo"; // Database name
$tbl_name="USERS"; // 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
$ParticipantID=$_POST["ParticipantID"];
$password=$_POST["UserPass"];
$sql = "SELECT ID FROM USERS WHERE ID = '$participantID'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
if($count==0)
{
$sql = "INSERT INTO USERS (ID, PASSWORD) VALUES ('$participantID', '$password')";
echo "Thank you for registering, you can now login:";
?>
<a href= http://www.arihealth.info/index.php>Login Page.</a>
<?php
} else {
echo "Your ID has already been registered:";
?>
<a href= http://www.arihealth.info/registerphp.php>Register Here.</a>
<?php
}
?>
爲了您的信息:MySQL是過時,使用庫MySQLi或PDO – Thamilan
您需要逃生者POST參數並從不將密碼存儲爲純文本! – Svetoslav