我遇到了我的表单问题。 我想使用电子邮件和密码创建注册表单。 但它没有插入我的数据库。注册表单Bootstrap PHP
我正确包括数据库连接,但我不知道为什么它没有插入。
这是我的PHP的注册
<?php
include ("dbconnection.php");
if(isset($_POST['submit'])) {
//gather all the data from the submission process
$email = $_POST['email'];
$password = $_POST['password'];
date_default_timezone_set('Asia/Manila');
$date_created = date('D, d M o h:i:s O', time());
$password = md5($password);
$check_email = mysql_query("SELECT email FROM tbl_clients WHERE email = '$email'") ;
$checked_email = mysql_num_rows($check_email);
if($checked_email != 0) {
echo"<script>alert('Sorry that email is already taken')</script>";
}
else {
$query = "INSERT INTO tbl_registration (email,
password,
created) VALUE
('".$email."',
'".$password."',
".$date_created.")";
$result = mysql_query($query);
echo"<script>alert('Thank you for registering. Your registration is successful!')
</script>";
}
}
?>
这是我的HTML
<div class="col-lg-5 col-lg-push-1 col-md-5 col-md-push-1 col-sm-7 col-sm-push-1 col-xs-
12">
<h3><b>Register</b></h3>
<form role="form" method="post" action="">
<div class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" name="email" placeholder="Email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password"
placeholder="Password">
</div>
<button type="submit" class="btn btn-default">Sign Up</button>
</div>
</form>
</div>
[ **请不要在新代码中使用'mysql_ *'函数**](http://bit.ly/phpmsql)。他们不再被维护[并被正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**粉红色框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://j.mp/PoWehJ)。 – h2ooooooo
另外,请使用'MD5' LOL之外的东西,比如'sha256' –
谢谢你的建议:) –