I have been trying to make a PHP script that sends email from a website but every time i try to send it just displays the PHP code on a blank page, here is my HTML code
<div class="contactcontent">
<h2>Постави прашање: </h2>
<form action="../pmp-dpatu/php/contact.php" method="post">
<strong>Име</strong><br>
<input type="text" name="cf_name"><br>
<strong>E-mail</strong><br>
<input type="text" name="cf_email"><br>
<strong>Текст</strong><br>
<textarea name="cf_message"></textarea><br>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
</div>
it works and is displayed properly in the browser but when i send an email it just goes to the PHP page. here is my PHP code
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'dpatu_mihajlo_pupin@yahoo.com';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to gordon@template-help.com');
window.location = 'contact_page.html';
</script>
<?php
}
?>