File manager - Edit - /home/justdoit/buildprosconnect.com/submit_job.php
Back
<?php require_once("db.php"); /* simple script*/ error_reporting(E_ALL); ini_set('display_errors', 1); date_default_timezone_set('Africa/Accra'); // Ensure proper sanitization of user inputs $services = mysqli_real_escape_string($conn, $_POST["services"]); $date = mysqli_real_escape_string($conn, $_POST["date"]); $time = mysqli_real_escape_string($conn, $_POST["time"]); $location = mysqli_real_escape_string($conn, $_POST["location"]); $tel = mysqli_real_escape_string($conn, $_POST["tel"]); $description = mysqli_real_escape_string($conn, $_POST["description"]); // Print current date and time $booking_date = date("Y-m-d H:i:s"); // Changed to use 24-hour format for time // Correct the SQL statement (SQL variable name case sensitivity) $sql = "INSERT INTO `booking`(`services`, `date`, `time`, `location`, `tel`, `description`, `booking_date`) VALUES ('$services', '$date', '$time', '$location', '$tel', '$description', '$booking_date')"; // Execute query $result = mysqli_query($conn, $sql); if ($result) { // Mail to $to = "buildprosconnect@gmail.com"; $subject = "New Booking"; $message = "<b>Booking Details.</b><br/><hr>"; $message .= "Date: " . $date . " .<br/>"; $message .= "Time: " . $time . " .<br/>"; $message .= "Location: " . $location . " .<br/>"; $message .= "Phone #: " . $tel . " .<br/>"; $message .= "Services needed: " . $services . " .<br/>"; $message .= "Description: " . $description . " .<br/>"; $message .= "Date/Time of booking: " . $booking_date . " .<br/>"; $from = "noreply@buildprosconnect.com"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $from . "\r\n" . 'Reply-To: ' . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion(); // Send email with proper 'from' address mail($to, $subject, $message, $headers, '-f noreply@buildprosconnect.com'); // Redirect after successful booking header("Location:booking_completed.php"); exit(); // It's a good practice to call exit after header redirection } else { // If the query fails, handle the error echo "Error: " . mysqli_error($conn); } ?> <?php $to = "buildprosconnect@gmail.com"; $subject = "Test Email"; $message = "This is a test email."; $headers = "From: noreply@buildprosconnect.com"; if (mail($to, $subject, $message, $headers)) { echo "Email sent successfully!"; } else { echo "Failed to send email."; } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0.74 |
proxy
|
phpinfo
|
Settings