I'm very new to coding, I started last week and I'm trying to create an appointment booking website for an ensurance company in my city. I have a single PHP file using both HTML and PHP languages because I found it more comfortable to work with the form, since I can display both the error message and the succes message under the "Submit" button. I was wondering if there is any way I can put the echo message inside a tag so i could edit it in css maybe creating a box around it or adding an icon to make it stand out more.
<button class="btn">Submit</button>
<?php
if ($_SERVER['REQUEST_METHOD']=='POST') {
htmlspecialchars($_SERVER["PHP_SELF"]);
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$date = $_POST["date"];
$time = $_POST["time"];
if (!empty($name) && !empty($email) && !empty($phone) && !empty($date) && !empty($time)) {
$host = "localhost";
$dbname = "appointments";
$username = "root";
$password = "";
$conn = mysqli_connect($host, $username, $password, $dbname);
if (mysqli_connect_errno()){
die("Connection error: " . mysqli_connect_errno());
}
$sql = "INSERT INTO appuntamenti (name, email, phone, date, time)
VALUES(?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if ( ! mysqli_stmt_prepare($stmt, $sql)) {
die(mysqli_error($conn));
}
mysqli_stmt_bind_param($stmt, "sssss",
$name,
$email,
$phone,
$date,
$time);
mysqli_stmt_execute($stmt);
echo "<Booking was successful";
}else {
echo "All fields need to be completed.";
}
}
?>
I was also wondering if there is anyway to remove weekends and holidays from the standard html5 datepicker using only PHP, I already got rid of past dates using this command
<input type="date" name="date" min="<?= date('Y-m-d') ?>">
Let me know if there's anything I'm doing wrong or I could better. Thanks in advance.