这是用户注册的我的 register.php 代码。当我点击我的“注册”提交按钮时,我得到了那些 sql 错误,我无法继续到我的标题位置是voting2.php ......请帮助。
<?php session_start(); ?>
<?php
require('connect/connect.php');
if(isset($_POST['submit'])){
$password1=$_POST['password1'];
$password2=$_POST['password2'];
if ($password1 == $password2) {
$studid = mysql_escape_string ($_POST['studid']);
$password1= mysql_escape_string ($password1);
$password2= mysql_escape_string ($password2);
$fname= mysql_escape_string($_POST['fname']);
$lname= mysql_escape_string ($_POST['lname']);
$mname= mysql_escape_string ($_POST['mname']);
$dob= mysql_escape_string ($_POST['dob']);
$address= mysql_escape_string ($_POST['address']);
$f_fname= mysql_escape_string($_POST['f_fname']);
$f_lname= mysql_escape_string($_POST['f_lname']);
$f_mname= mysql_escape_string($_POST['f_mname']);
$m_fname= mysql_escape_string($_POST['m_fname']);
$m_lname= mysql_escape_string($_POST['m_lname']);
$m_mname= mysql_escape_string ($_POST['m_mname']);
$sql1 = "SELECT * FROM `new_reg_student` WHERE `password` = '". $password1 ."' AND `studid` = '". $studid ."'";
//this is my line 27 error
if (mysql_num_rows ($sql1) == 1) {
echo "Password & Student ID already exists.";
exit();
}
$sql3 = "INSERT INTO `new_reg_student` (`id`, `studid`, `password`, `fname`, `lname`, `mname`, `dob`, `address`, `f_fname`, `f_mname`, `f_lname`, `m_fname`, `m_mname`, `m_lname`) VALUES (NULL, '$studid', '$password1', '$fname', '$lname', '$mname', '$dob', '$address', '$f_fname', '$f_mname', '$f_lname', '$m_fname', '$m_mname', '$m_lname')" ;
$result = mysql_query($sql3) or die (mysql_error()) ;
//this is my line 35 error
if(mysql_num_rows($result) > 0) {
header("Location: voting2.php");
exit();
} else {
echo " ";
exit();
}
}
else {
echo " Sorry password do not match";
exit();
}
}
?>
这是我的 register.php 的正文内容
<h2>Please Register Using The Form Below</h2>
<fieldset><legend><h1>Student Info</h1></legend>
<table>
<tr>
<td height="500">
<form id="regform" method="post" action="register2.php">
<ul>
<li><label>Student ID:</label><br />
<div id="txtbox"><input type="text" id="" name="studid" readonly="readonly" value="<?php echo $_SESSION['username']; ?>" /></div>
</li>
<li><label>Password:</label><br />
<div id="txtbox"><input type="password" id="password1" name="password1" /></div>
</li>
<li><label>Confirm Password:</label><br />
<div id="txtbox"><input type="password" id="password2" name="password2" /></div>
</li>
<li><label>Name:</label><br />
<div id="txtbox"><input value="Fist Name" type="text" name="fname"/> - <input value="Middle Name" type="text" name="mname"/> - <input value="Last Name" type="text" name="lname"/></div>
</li>
<li><label>Date of Birth:</label><br />
<div id="txtbox"><input type="text" name="dob" value="Year-Month-Day" /> - ex. 2013-12-01</div>
</li>
</li><li><label>Address:</label><br />
<div id="txtbox">
<input type="text" name="address" />
</div>
</li>
<li><label>Your Father's Name:</label><br />
<div id="txtbox"><input value="Fist Name" type="text" name="f_fname"/> - <input value="Middle Name" type="text" name="f_mname"/> - <input value="Last Name" type="text" name="f_lname"/></div>
</li>
<li><label>Your Mother's Name:</label><br />
<div id="txtbox"><input value="Fist Name" type="text" name="m_fname"/> - <input value="Middle Name" type="text" name="m_mname"/> - <input value="Last Name" type="text" name="m_lname"/></div>
</li>
</ul>
<p id="wa"><input type="submit" id="submit" value="Register" name="submit"/></p>
</form>
</table>
<p id="helper"></p>
</td></fielset>
</div>