I am trying to get my HTML form to post to my data base but I get nothing. I am not bothered about the security side of things at the moment I would just like it functional. I have looked all over the web for a solution and at most of the similar problems on here. I am probably just missing something stupid.


  <form action="booking.php"  id="booking" name="booking" method="post">
       Let us know what you would like and when and we will get back to you 
       to confirm<br>
         <label for="name">Name:</label>
         <input type="text" id="name" name="name"><br>
         <label for="email">Email:</label>
         <input type="email" name="email" id="email" required>`



define('db_database', 'database');
define('db_user_name', 'username');
define('db_password', 'password');
define('db_server_name', 'server');

$dbconnect = mysqli_connect(db_server_name, db_user_name, db_password, 

if (!$dbconnect) {
die('Could not connect: ' . mysqli_error());

echo 'Connected!';

$db_selected = mysqli_select_db($dbconnect, db_database);

     $name = $_POST['name'];

     $mysqli = "INSERT INTO booking (name) VALUES ($name)"; 


MySQL returned an empty result set (i.e. zero rows). (Query took 0.0004 seconds.)

1 Answers

JavaMensch On
  1. Make sure that the name attribute in the input tag from your name is defined as name like: <input type="text" name="name"> Without this you can't access. Check if you get the value of the submitted form like: echo $_POST["name"]

I would recommend to get the $name variable in the SQL-Query like this: INSERT INTO booking (name) VALUES ('$name')

If it's not working after all, try to execute the query like this:

$result = mysqli_query($dbconnect, $mysqli);

(instead of your $db_selected part)

I hope I can help.