I have made some changes to my code based on suggestions on forums. I am quite certain that my connection to the database is fine, however, the data on the form is not posting into my database.
I was told to change:
$result = mysqli_query($dbc, $query) or die('Error querying database.');
to this:
$result = mysqli_query($dbc, $query) or die(mysql_error());
in order to identify the error. However, when I run the script with:
$result = mysqli_query($dbc, $query) or die('Error querying database.');
it goes to an error page that reads:
Error querying database.
When I use:
$result = mysqli_query($dbc, $query) or die(mysql_error());
it goes to what looks like an identical error page with no message at all.
Below is the code I have now:
<?php
$dbc = mysqli_connect('localhost', 'circlema_shnips6', 'rhiannon', 'circlema_propertydatabase')or trigger_error(mysql_error(),E_USER_ERROR);
$property_type = $_POST['property_type'];
$number_of_bedrooms = $_POST['#_of_bedrooms'];
$number_of_bathrooms = $_POST['#_of_bathrooms'];
$state_province = $_POST['state_province'];
$city = $_POST['city'];
$address = $_POST['address'];
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$additional_info = $_POST['additional_info'];
$query = "INSERT INTO circlema_propertydatabase (property_type,number_of_bedrooms,number_of_bathrooms,state_province,city,address,name, email,phone,additional_info) VALUES('$property_type','$number_of_bedrooms','$number_of_bathrooms','$state_province','$city','$address','$name','$email', '$phone','$additional_info')";
$result = mysqli_query($dbc, $query) or die(mysql_error());
mysqli_close($dbc);
?>
I would really appreciate any help. As well, if possible, I would like to direct the user to thankyou.html if the data successfully posts in my database.
Any help with the code required for that would be greatly appreciated.
Thanks again for all the previous suggestions.