我目前正在尝试使我的登录/注册表单正常工作。登录部分可以处理任何问题,但是正确提交Register.html。这将被插入到DB的表中:
-- Table structure for table `userlogin`
--
CREATE TABLE `userlogin` (
`userid` int(20) NOT NULL auto_increment,
`Username` text NOT NULL,
`Password` text NOT NULL,
`Email` text NOT NULL,
`Phone Number` text NOT NULL,
`Carrier` text NOT NULL,
`Service Status` text NOT NULL,
`Service Info` text NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2369 ;
INSERT INTO `userlogin` VALUES(2367, '123', '1', '111@gmail.com', '', 'Verizon', '', '');
从DB复制。 最后两列应该是空白的,但电话号码列未填写。这是我的代码。为什么我的电话号码栏没有填充?谢谢你的帮助。
Register.html
<form action="Register_check.php" method="post">
<p>Username:</p>
<input type="text" size="30" name="Username" />
<p>Password:</p>
<input type="password" size="30" name="Password" />
<p>Re-type Password:</p>
<input type="password" size="30" name="PasswordConfirm" />
<p>Email Address:</p>
<input type="email" size="30" name="Email" />
<p>Mobile Phone Number:</p>
<input type="tel" pattern="[0-9]{10}" name="Phone Number" />
<p>Carrier:</p>
<input type="text" size="30" name="Carrier" />
<br />
<input type="submit" value="register">
</form>
<p>Already have an account?<a href="Login.html">Login</a></p>
Register_check.php
<?php
include ("cn.php");
if(mysql_num_rows(mysql_query("SELECT * from userlogin WHERE Username='" . $_POST['Username'] . "'")) == 1){
echo "<font color='red'>Sorry, that username is already in use</font>";
}
else if(strlen($_POST['Username']) ==0){
echo "<font color='red'>Please enter a desired user name!</font>";
}
else if($_POST['Password'] != $_POST['PasswordConfirm']){
echo "<font color='red'>Oops! The two entered passwords don`t match!</font>";
}
else if(strlen($_POST['Password']) ==0){
echo "<font color='red'>Please enter a password!</font>";
}
else if(strlen($_POST['Email']) ==0){
echo "<font color='red'>Please enter your email address</font>!";
}
else if(strlen($_POST['Phone Number']) ==0){
echo "<font color='red'>Please enter your Mobile phone number with out spaces,- or ()!</font>";
}
else if(strlen($_POST['Carrier']) ==0){
echo "<font color='red'>Please enter your Mobile phone carrier!</font>";
}
else{
mysql_query("INSERT into userlogin VALUES('".$_POST['userid']."','".$_POST['Username']."','".$_POST['Password']."','".$_POST['Email']."','".$_POST['Phone Number']."','".$_POST['Carrier']."','".$_POST['Service Status']."','".$_POST['Service Info']."')") or die(mysql_error());
}
?>
<form action="Register_check.php" method="post">
<p>Username:</p>
<input type="text" size="30" name="Username" />
<p>Password:</p>
<input type="password" size="30" name="Password" />
<p>Re-type Password:</p>
<input type="password" size="30" name="PasswordConfirm" />
<p>Email Address:</p>
<input type="text" size="30" name="Email" />
<p>Mobile Phone Number:</p>
<input type="tel" pattern="[0-9]{10}" name="Phone Number" />
<p>Carrier:</p>
<input type="text" size="30" name="Carrier" />
<br />
<input type="submit" value="register">
</form>
答案 0 :(得分:0)
将您的html“PhoneNumber”和php中的电话号码名称更改为$ _POST [“PhoneNumber”]