PHP Connection Database Issues
Help me look, the database is not content, but I look at the feeling is right
<title>Untitled Document</title>
User Login
Include "comm.php";
?>
<title>Online Message-Message board</title>
if (isset ($_post[' username ')) {
$user = $_post[' username ');
$PW = MD5 ($_post[' PW1 ');
$conn = mysql_connect ("localhost", "root", "123456");
mysql_select_db ("Car");
$sql = "INSERT into Car_user (USER_NAME,PW) VALUES (' $user ', ' $PW ')";
mysql_query ("Set names ' gb2312 '");
mysql_query ($sql, $conn);
Mysql_close ($conn);
Get_show_msg ("left.html", "registered success");
}
?>
------Solution--------------------
mysql_query ($sql, $conn) or Die (Mysql_error ()); Do you have any error message?
------Solution--------------------
mysql_query ($sql, $conn) or Die (Mysql_error ());
------Solution--------------------
HTML code
#js中pw1, pw2 undefined, return stopped, the following code does not execute if ( myform.pw1.value== "" | myform.pw2.value== "") {alert ("Password cannot be empty!"); return false;} #改为
#后面添加
#导致php页面 $PW = MD5 ($_post[' PW1 ']); #没有值, don't believe you echo come out try instead: $conn = mysql_connect ("localhost", "root", "123456"); mysql_select_db ("Car"); $sql = "INSERT into Car_user (USER_NAME,PW) VALUES (' $user ', ' $PW ')"; mysql_query ("Set names ' gb2312 '"); $res = mysql_query ($sql, $conn); #如果sql未执行成功, print out the error if (! $res) die ("sql:{$sql}
Error:". Mysql_error ()); if (mysql_affected_rows () > 0) get_show_msg ("left.html", "registered successfully"); else echo "registration failed". Mysql_error (); Mysql_close ($conn);