Internal server error means there’s an error in your server side script, in this case :
$to = "[email protected],$email" // missing a semicolon
The missing semicolon above triggers Unexpected ‘$subject’ (T_VARIABLE)
also here :
$subject= "Thankyou $name - Your repair has been logged"
this is the code you should use :
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("#", "#", "#", "#");
// Check connection
if ($link === false) {
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$name = $_POST['name'];
$initials = $_POST['initials'];
$item = $_POST['item'];
$issue = $_POST['issue'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$cost = $_POST['cost'];
$loggedby = $_POST['loggedby'];
$bag = $_POST['bag'];
$charger = $_POST['charger'];
// attempt insert query execution
$sql = "INSERT INTO `repairs` (`name`,`initials`,`item`, `issue`, `telephone`,`email`, `cost`, `loggedby`, `bag`, `charger`) VALUES (?,?,?,?,?,?,?,?,?,?)";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_bind_param($stmt, 'ssssssssss', $name, $initials, $item, $issue, $tel, $email, $cost, $loggedby, $bag, $charger);
if (mysqli_stmt_execute($stmt)) {
$to = "[email protected],$email";
$subject = "Thankyou $name - Your repair has been logged";
$body = "<h2>Thankyou $name</h2> /n
This is a confirmation email regarding your $item /n
Your repair log is below: /n
$item /n
$issue /n/n
<h3>Accessories</h3> /n
bag - $bag /n
charger - $charger /n/n
Your repair was logged by $loggedby on " . date("d-m-Y") . "/n/n
We will contact you on $tel & $email when your $item is ready to
collect.
/n/n
Loud Crowd IT - 01302 965482 /n
[email protected] /n
www.loudcrowd.agency /n";
if (mail($to, $subject, $body)) {
header('location:repairs.php');
}
} else {
printf("Error: %s.\n", mysqli_stmt_error($stmt));
}
mysqli_close($stmt);
// close connection
mysqli_close($link);
?>
2
solved PHP to SQL and email form submission