Reputation: 2439
I am having problem with my form. I want to create a registration form using an email and password. But it is not inserting on my database.
I include the database connection correctly but I don't know why it s not inserting.
This is my PHP for the registration
<?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>";
}
}
?>
This is my 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>
Upvotes: 0
Views: 1909
Reputation: 812
You need to write VALUES not VALUE
$query = "INSERT INTO tbl_registration (email,
password,
created) VALUES
('".$email."',
'".$password."',
".$date_created.")";
And BTW, i recommending to you to salt the password
Upvotes: 1