我正在尝试创建一个注册表单,但我无法将用户的电子邮件发送到sql数据库。
这是我的HTML表单代码
<form class="form-login" action="register.php" method="POST">
<h2 class="form-login-heading">sign up now</h2>
<div class="login-wrap">
<input type="text" class="form-control" placeholder="First Name" name="first" autofocus>
<br>
<input type="text" class="form-control" placeholder="Last Name" name="last">
<br>
<input type="text" class="form-control" placeholder="Email" name="email">
<br>
<input type="text" class="form-control" placeholder="Username" name="username">
<br>
<input type="password" class="form-control" placeholder="Password" name="password">
<label class="checkbox">
<span class="pull-right">
<a href="resetpassword.html"> Forgot Password?</a>
</span>
</label>
<button class="btn btn-theme btn-block" type="submit"><i class="fa fa-lock"></i> SIGN UP</button>
<hr>
<div class="login-social-link centered">
<p>or you can sign in via your social network</p>
<button class="btn btn-facebook" type="submit"><i class="fa fa-facebook"></i> Facebook</button>
<button class="btn btn-twitter" type="submit"><i class="fa fa-twitter"></i> Twitter</button>
</div>
<div class="registration">
Don't have an account yet?<br/>
<a class="" href="#">
Create an account
</a>
</div>
</div>
<!-- Modal -->
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Forgot Password ?</h4>
</div>
<div class="modal-body">
<p>Enter your e-mail address below to reset your password.</p>
<input type="text" name="email" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
<button class="btn btn-theme" type="button">Submit</button>
</div>
</div>
</div>
</div>
<!-- modal -->
</form>
这里是我正在使用的php代码,以下php代码只能插入名字,姓氏,用户名和密码,但电子邮件被遗漏了。我在另一个表单上尝试了相同的PHP代码,这似乎工作正常。有人能解释我哪里错了吗?
$first = $_POST['first'];
$last = $_POST['last'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
以下是我的sql代码,用于将数据插入到数据库中,其余代码建立连接,一切似乎都正常工作。那么有人可以告诉我哪里出错了吗?
$sql = "INSERT INTO registeredusers (FirstName,LastName,UserName,Email,Password)
VALUES ('$first','$last','$username_lower','$email','$encryptedPWD')";
这里是sql
结构
CREATE TABLE 'registeredusers' (
'id' int(11) NOT NULL,
'FirstName' varchar(50) NOT NULL,
'LastName' varchar(50) NOT NULL,
'UserName' varchar(50) NOT NULL,
'Email' varchar(50) NOT NULL,
'Password' varchar(255) NOT NULL,
'ResetPassword' int(7) DEFAULT NULL,
'friends' int(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
答案 0 :(得分:5)
我看到您在单个name="email"
代码中有form
的2个输入(在注册表单中,忘记密码表单) 。这是唯一的原因。
作为建议,您应该使用单独的表单标记或使用email
输入的不同名称。