我目前正在为我的网站注册页面。我只是需要一些帮助,因为我不确定为什么当我输入注册详细信息(只有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