Edit: (answer follows)
Special note: I noticed that you have not accepted any answers given to any of your questions, where a solution was indeed found.
The way that the StackOverflow system works is that, once an answer has been given to a problem, you then tick the white checkmark till it turns green.
Have a look at the following article on "How does accepting an answer work".
StackOverflow is built on a points/reputation system to encourage everyone for its continued success.
Read the "about" section:
Answer
Adding error reporting to your files would have signaled the mistake.
error_reporting(E_ALL);
ini_set('display_errors', 1);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
You either don't use quotes around table names or use backticks if it's an MySQL reserved word; in this case it isn't so just remove the quotes around your table name.
$res = mysqli_query($con,"INSERT INTO boatviewing (clientNo,boatNo,viewDate,comment)
(if you really want to escape your table name)
$res = mysqli_query($con,"INSERT INTO `boatviewing` (clientNo,boatNo,viewDate,comment)
You also seem to have an extra <form>
tag; remove it, plus remove the extra semi-colon at the end of die(mysqli_error());;
it's not needed.
Another thing, remove the echo "success";
above your header("Location:client.php");
, you are outputting before header and will throw an error.
Change
$con = mysqli_connect("localhost","root","","boats4u")or die(mysqli_error());;
to:
$con = mysqli_connect("localhost","root","","boats4u")
or die("Error " . mysqli_error($con));
as per the method that the manual states:
Sidenote: Your present code is open to SQL injection. Use prepared statements, or PDO.
Here is a prepared statement method:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost","root","","boats4u");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* Set the params */
$client = $_POST['clientNo'];
$boat = $_POST['boatNo'];
$date = $_POST['viewDate'];
$comment = $_POST['comment'];
/* Create the prepared statement */
if ($stmt = $mysqli->prepare("INSERT INTO boatviewing (clientNo,boatNo,viewDate,comment) VALUES (?, ?, ?, ?)")) {
/* Bind the params */
$stmt->bind_param('ssss', $client, $boat, $date, $comment);
/* Execute the prepared statement */
$stmt->execute();
/* Echo results */
echo "Inserted {$client}, {$boat}, {$date}, {$comment} into database.\n";
/* Close the statement */
$stmt->close();
}
else {
/* Error */
printf("Prepared Statement Error: %s\n", $mysqli->error);
}
?>
If you don't want to use prepared statements (which you really should) and are in a learning state, at least use some protection using mysqli_real_escape_string()
$client = mysqli_real_escape_string($con,$_POST['clientNo']);
$boat = mysqli_real_escape_string($con,$_POST['boatNo']);
$date = mysqli_real_escape_string($con,$_POST['viewDate']);
$comment = mysqli_real_escape_string($con,$_POST['comment']);