Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if(empty($error)){
		$sql="SELECT*FROM user_d WHERE email = '".$
		$result= $conn->query($sql);
		$customer_data=array();
		if($result->num_rows > 0){
			$error[] = "Email already exist!";
		}
		else{
			$error=array();
			$sql="INSERT INTO
	user_d(`f_name`,`l_name`,`dob`,`email`,`password`);
	VALUES($fname,$lname,$dob,$email);
		if($conn->query($sql)===TRUE){
			$success[]= "Account created successfully";
		} else{
			$errors[] = "Error:".$sql."<br>".$conn->error;
		}
	}
}	
$_SESSION['error']=$error;
$_SESSION['success']=$success;
header("Location:register_customer.php');


What I have tried:

$success[]= "Account created successfully";
$success()= "Account created successfully";
Posted
Updated 9-May-21 17:29pm

1 solution

PHP
$sql="SELECT*FROM user_d WHERE email = '".$
// Previous line is truncated


PHP
        $sql="INSERT INTO
user_d(`f_name`,`l_name`,`dob`,`email`,`password`);
VALUES($fname,$lname,$dob,$email);
// double quote is missing here  ^

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900