我没有看到问题。我的所有数据都不会插入注册数据库。请检查 INSERT INTO 部分。我是编码的初学者,所以我不太了解这些东西。请帮我。
<?php
**my info is here**
//Connect to database
mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
?>
<?php
if(isset($_POST['submit'])){
$username = $_POST[user];
$password = $_POST[pass];
// lets check to see if the username already exists
$checkuser = mysql_query("SELECT username FROM register WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "I'm sorry but the username you specified has already been taken.Please pick another one.";
unset($username);
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = ("INSERT INTO register (username, password)
VALUES ('$username', '$password')");
mysql_query($query) or die(mysql_error());
mysql_close($query);
}
?>