I am using this code to submit and store data in the database. I want if an email already exists then show a message like your email already exists. code:
<?PHP
$con = mysqli_connect('localhost','rrrradadf','-rfsg?%DXFK#');
// servername => localhost
// username => -rfsg?%DXFK#'
// password => -rfsg?%DXFK#'
// database name => rrrradadf
$conn = mysqli_connect("localhost", "rrrradadf", "-rfsg?%DXFK#'", "rrrradadf");
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form data(input)
$email = $_REQUEST['email'];
// Performing insert query execution
// here our table name is college
$sql = "INSERT INTO emailtable VALUES ('','$email')";
if(mysqli_query($conn, $sql)){
header('location:index.html');
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>