I have a form that I am using to add information to a database, but the query will not run properly and the information is not being added at all.
This is the php code I am trying to execute, but it keeps hitting the first error or completely going to the last else statement:
<?php
if (!isset ($_POST['submit']))
{
include ("add_contact.php");
}
else
{
$name = $_POST['Name'];
$phone_num = $_POST['main_num'];
$sec_num = $_POST['sec_num'];
$email = $_POST['email'];
$cus_type=$_POST['cusType'];
$business = $_POST['business'];
$address = $_POST['address'];
$service = $_POST['service'];
$notes = $_POST['comment'];
include ("dbcon.php");
fopen ("dbcon.php", "r"); //used because of bad experiences prior with include() only
if ($cus_type == 'Corporate'){
$result = mysqli_query($connect,"INSERT INTO customers WHERE ('$name', '$phone_num', '$cus_type', '$sec_num', '$email', '$address', '$business', '$service', '$notes') ");
if ($result){
echo "Thank you for adding the Contact to the Database!";
}
else{
echo "ERROR: Corporate Customer Not Added to Database";
}
}
else if ($cus_type == 'Private'){
$result = mysqli_query($connect,"INSERT INTO private_customers WHERE ('$name', '$phone_num', '$cus_type', '$sec_num', '$email', '$address', '$business', '$service', '$notes') ");
if ($result){
echo "Thank you for adding the Contact to the Database!";
}
else{
echo "ERROR: Private Customer Not Added to Database";
}
}
else{
echo "Contact Invalid. Please Try Again.";
}
}
?>
Any comments or answers would be helpful to spot what is going wrong in my code. Also just a note, this is for an internal website for a company and no one here (besides the one who told me to make this) knows MYSQL and PHP.