I keep getting this error displayed in a new page
Error: Duplicate entry 'company' for key 'cname'
how can i display this in a new header
Heres my code:
$con=mysqli_connect("localhost","root","password","mydb");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO profile (cname, cobusiness, cphone,crep,cdescription)
VALUES
('$_POST[cname]','$_POST[cobusiness]','$_POST[cphone]','$_POST[crep]','$_POST[cdescription]')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
header("Location: home.php?error");
} else {
header("Location: home.php?success");
exit;
}
mysqli_close($con);
I have added a trigger in mysql to check for duplicate entries and just need to figure out how to prevent this duplicate entry error display in a new page by default.This way i can display it in a header on the current page like i have already done with the other headers in the code.