PHP 表单选择和单选错误我有一个表单,但是在选择按钮和单选按钮上出现 php 错误我得到的错误是 $age 和 $gender
如何在同一页打印错误信息?
这是php代码
$firstname=""; $lastname=""; $email=""; $re_email="";
if(isset($_POST['register'])){
$firstname=strip_tags($_POST['firstname']);
$lastname=strip_tags($_POST['lastname']);
$email=strip_tags(strtolower($_POST['email']));
$re_email=strip_tags(strtolower($_POST['re_email']));
$password=strip_tags($_POST['password']);
$re_password=strip_tags($_POST['re_password']);
$age=$_POST['age'];
$gender=$_POST['gender'];
$date=date("Y-m-d");
if($firstname && $lastname && $email && $re_email && $password && $re_password && $age && $gender){}
else{die("Please fill in all fields");}
//USERNAME CHECKING//////////////////////////////////////////////////////////////////
$connect=mysql_connect("localhost", "root", "");
$database=mysql_select_db("phplogin", $connect);
$namecheck=mysql_query("SELECT email FROM users WHERE email='$email'");
$count=mysql_num_rows($namecheck);
if($count!=0)
{die("Username already taken");}
这是HTML代码
<html>
<H1>Register</H1>
<form action="register.php" method="POST">
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="firstname" value="<?PHP echo $firstname;?>" maxlength="25"/></td>
<td>Maxium 25 characters</td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" value="<?PHP echo $lastname;?>"maxlength="25"/></td>
<td>Maxium 25 characters</td>
</tr>
<tr>
<td>email:</td>
<td><input type="text" name="email" value="<?PHP echo $email;?>"maxlength="40"/></td>
<td>Maxium 40 characters</td>
</tr>
<tr>
<td>Re-enter email:</td>
<td><input type="text" name="re_email" value="<?PHP echo $re_email;?>"maxlength="40"/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" maxlength="25"/></td>
<td>Password must be between 6 and 25 characters</td>
</tr>
<tr>
<td>Re-eneter Password:</td>
<td><input type="password" name="re_password" maxlength="50"/></td>
</tr>
</table>
<select>
<option value="">Age</option>
<option name="age" value="18-29">18-29</option>
<option name="age" value="30-39">30-39</option>
<option name="age" value="40-49">40-49</option>
<option name="age" value="50-59">50-59</option>
<option name="age" value="60-69">60-69</option>
<option name="age" value="70">70 Plus</option>
</select>
<input type="radio" name="gender" value="male" />Male
<input type="radio" name="gender" value="female" />Female
<input type="submit" name="register" value="Register" />
</form>
</html>