我将在 php 中创建一个注册,但它向我显示以下错误:
字符串(59)“插入用户(用户名,电子邮件,密码)值('','','')”键'电子邮件'的重复条目''
<?php
$con = mysql_connect("localhost", "user", "");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("university", $con);
$res = mysql_query("INSERT INTO users (username, password, email) VALUES('{$_POST['uname']}', '{$_POST['pwd']}', '{$_POST['email']}')");
if (!$res) {
echo "MYSQL ERROR ->" . mysql_error();
} else {
echo '<script type="text/javascript">alert(\'Regjistrimi u krye me sukses!\')</script>';
}
?>
这是 html 中的表单。我看不出哪里有问题
<div id="containt" align="right">
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" id="registration_form">
<table border="0">
<tbody>
<tr>
<td><label for="name">Your Name*: </label> </td>
<td><input id="name" maxlength="45" name="name" type="text" /> </td>
</tr>
<tr>
<td><label for="email">Email*:</label> </td>
<td><input id="email" maxlength="45" name="email" type="text" /></td>
</tr>
<tr>
<td><label for="username">Username*:</label> </td>
<td><input id="username" maxlength="45" name="uname" type="text" /> </td>
</tr>
<tr>
<td><label for="password">Password*:</label></td>
<td><input id="password" maxlength="45" name="pwd" type="password" /></td>
</tr>
<tr>
<td align="right"><input name="Submit" type="submit" value="Regjistro" /></td>
</tr>
</tbody></table>
</form>
</div>