I got this free bootstrap temp for a restaurant. And I am trying to make my first contact form, but I have no idea how this works as it is so different from HMTL code.
I take it I have to change the PHP and put my own email address in it at $toEmail
but when I try it and test it on XAMPP it does not work.
I have this for my PHP:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$ToEmail = 'test@test.com';
$EmailSubject = $_POST['subject'];
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Subject:".$_POST['subject']."<br />";
$MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."<br>";
if(mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader))
{
echo "<script>alert('Mail was sent !');</script>";
echo "<script>document.location.href='http://localhost/restaurant/'</script>";
}
else
{
echo "<script>alert('Mail was not sent. Please try again later');</script>";
}
}
And this in my html
<div class="inner contact">
<!-- Form Area -->
<div class="contact-form">
<!-- Form -->
<form id="contact-us" method="post" action="contact.php">
<!-- Left Inputs -->
<div class="col-md-6 ">
<!-- Name -->
<input type="text" name="name" id="name" required class="form" placeholder="Naam" />
<!-- Email -->
<input type="email" name="email" id="email" required class="form" placeholder="Email Adres" />
<!-- Subject -->
<input type="text" name="subject" id="subject" required class="form" placeholder="Onderwerp" />
</div><!-- End Left Inputs -->
<!-- Right Inputs -->
<div class="col-md-6">
<!-- Message -->
<textarea name="message" id="message" class="form textarea" placeholder="Bericht"></textarea>
</div><!-- End Right Inputs -->
<!-- Bottom Submit -->
<div class="relative fullwidth col-xs-12">
<!-- Send Button -->
<button type="submit" id="submit" name="submit" class="form-btn semibold">Verstuur Bericht</button>
</div><!-- End Bottom Submit -->
<!-- Clear -->
<div class="clear"></div>
</form>
</div><!-- End Contact Form Area -->
Can someone please point me in the right direction? Which parts do i need to edit for it to work?