某些原因我在以下代码中收到未定义的索引错误。任何帮助,将不胜感激。这是我收到的错误
Notice: Undefined index: username in C:\xampp\htdocs\register.php on line 5
Notice: Undefined index: password in C:\xampp\htdocs\register.php on line 6
Notice: Undefined index: firstname in C:\xampp\htdocs\register.php on line 7
Notice: Undefined index: surname in C:\xampp\htdocs\register.php on line 8
代码:
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("clubresults") or die(mysql_error());
$username = $_POST['username'];
$password = md5($_POST['password']);
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$sql = "INSERT INTO members (Username, Password, Firstname, Surname) VALUES ($username, $password, $firstname, $surname);";
mysql_query($sql);
?>
<html>
<div class="content">
<center>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Register</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="60">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="password" maxlength="10">
</td></tr>
<tr><td>Firstname:</td><td>
<input type="text" name="firstname" maxlength=210">
</td></tr>
<tr><td>Surname:</td><td>
<input type="text" name="surname" maxlength=210">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit"
value="Register"> </th></tr> </table>
</form>
</center>
</div>
</html>