Link to home
Start Free TrialLog in
Avatar of Jazzy 1012
Jazzy 1012

asked on

Insert data into database

<?php

require "connection.php";


if ($_POST['firstname'] != "" && $_POST['lastname'] !="" && $_POST['email'] != "" && $_POST['cemail'] !="" && $_POST['password'] !="" && $_POST['birthday'] !="" && $_POST['gender'] !="")
{
	$firstname = $_POST['firstname'];
	$lastname = $_POST['lastname'];
	$email = $_POST['email'];
	$cemail = $_POST['cemail'];
	$password = $_POST['password'];
	$birthday = $_POST['birthday'];
	$gender = $_POST['gender'];

	
	if($email != $cemail)
	{
		echo "email not same";
		die;
	}
	
	$query1="SELECT * FROM users WHERE firstname = '$firstname' ";	
	
	
	
	$result = mysqli_query($conn,$query1)
	or die(mysqli_error($conn));  

	
	if(mysqli_num_rows($result) != 0)
	{
		header("Location: index.php/?a=1");
	}
	else {
	$query = "INSERT INTO users (firstname,lastname,email,password,date of birth,gender) VALUES ('$firstname','$lastname','$email','$password', '$birthday' , '$gender')";
	$data = mysqli_query($conn,$query)or die(mysqli_error($conn));
	
	header("Location: index.php/?a=2");
	  
	}
	
}

Open in new window


I have this code to insert what was in my form to here, the data passes but it just doesnt add to my database, anyone know why?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jazzy 1012
Jazzy 1012

ASKER

Yes it was because of date of birth, thank you!