- Column count doesn't match value count at row 1
I am a little confused as to why this isn't working, everything seems to be okay, I can connect to the database, but it won't insert the data into the database.
Here is my code:
- <?php
- session_start();
- require("connect.php");
- if($_POST['submit'])
- {
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $conf_password = $_POST['conf_password'];
- $dob_year = $_POST['dob_year'];
- $dob_month = $_POST['dob_month'];
- $dob_day = $_POST['dob_day'];
- $gender = $_POST['gender'];
- $email = $_POST['email'];
- if(
- $firstname&&
- $lastname&&
- $username&&
- $password&&
- $conf_password&&
- $dob_year&&
- $dob_month&&
- $dob_day&&
- $gender&&
- $email)
- {
- if(strlen($firstname)>25 || strlen($lastname)>25 || strlen($username)>25 ) {
- echo "<center><div class='errorreg'>Firstname, Lastname and username must be no more than 25 charatcers.</div></center>";
- }
- else {
- if(strlen($password)>25||strlen($password)<6)
- echo "<center><div class='errorreg'>Password must be between 6 and 25 characters</div></center><br />";
- else
- {
- if(is_numeric($dob_year)&&is_numeric($dob_month)&&is_numeric($dob_day))
- {
- if(strlen($dob_year)>4||strlen($dob_month)<2||strlen($dob_year)<2){
- echo "<center><div class='errorreg'>Date of birth year must be 4 characters, month and day must be 2</div></center><br />";
- }
- else {
- if ($gender=="Male"||$gender="Female")
- {
- if($password==$conf_password){
- if($dob_month>12||$dob_day>31)
- echo "<center><div class='errorreg'>Date of birth is incorrect value!</div></center>";
- $query = mysql_query("SELECT * from users WHERE username='$username'");
- if (mysql_num_rows($query)>=1)
- echo "<center><div class='errorreg'>Sorry, the username, ".$username." is already taken.</div></center><br />";
- else {
- $dob_db = "$dob_year-$dob_month-$dob_day";
- $password_db = md5($password);
- $register = mysql_query("INSERT INTO users VALUES ('','$firstname','$lastname','$username','$password_db','$email','$dob_db','$gender')");
- echo "<center><div class='comreg'>
- Thank you for registering. You may now log into your account.</div></center><br />";
- }
- }
- else {
- echo "<center><div class='errorreg'>Passwords do not match</div></center>";
- }
- }
- else {
- echo "<center><div class='errorreg'>Gender must be Male or Female</div></center>";
- }
- }
- }
- else {
- echo "<center><div class='errorreg'>Date of birth must be in number form.</div></center>";
- }
- }
- }
- } else {
- echo "<center><div class='errorreg'>Oops! Something went wrong, please make sure you filled in all the fields.</div></center><br />";
- }
- }
- ?>
I'd appreciate some help on this, thanks!
