我遇到了我的表單問題。 我想使用電子郵件和密碼創建註冊表單。 但它沒有插入我的數據庫。註冊表單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' –
謝謝你的建議:) –