Firstly, I'm very novice to HTML/CSS/PHP. The problem is that when hitting submit on my contact form, I get the php action code on screen instead of the execution of it.
I have read that this happens when not running the code as local host with php interpreter. The problem here is that I am trying to run my contact form from my web hotel configured as PHP7.4, Apache2.4 UNIX which makes me confused as to why it occurs.
Here is my code,
Contact form
<form id="contact-form" method="post" action="contact-form-handler.php">
<div class="form-control narrow">
<label for="name">Car</label>
<input name="car" id="car" placeholder="Audi A3" type="text">
</div>
<div class="form-control narrow">
<label for="name">Reg</label>
<input name="reg" id="reg" type="text">
</div>
<div class="form-control narrow">
<label for="email">Mail</label>
<input name="email" id="email" type="email">
</div>
<div class="form-control narrow">
<label for="name">Phone</label>
<input name="phone" id="phone" type="text">
</div>
<div class="form-control">
<label for="message">Message</label>
<textarea name="message" id="message" rows="4"></textarea>
</div>
<ul class="actions">
<li><input type="submit" value="Send"></li>
</ul>
</form>
The PHP file
<?php
$type = $_POST['type'];
$reg = $_POST['reg'];
$visitor_email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$email_from = 'name@gmail.com';
$email_subject = "New request";
$email_body = "Type: $type.\n".
"Reg: $reg.\n".
"Mail: $visitor_email.\n".
"Tel: $phone.\n".
"Msg: $message.\n";
$to = "name2@gmail.com";
$headers = "From: $email_from \r\n";
$headers = "Reply-To: $visitor_email" \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: index.html");
?>
Any ideas?