Hi, I created an e-mail contact form on my website and have also created a PHP script to handle mailing. However, when I click on the submit button of my form so that the script will send the e-mail, it downloads the .php file instead of using it. The form on the HTML document looks like this:
<table>
<form method="post" action="mailform.php">
<tr>
<td class="formtext">Name: </td>
<td class="contactbox"><input type="text" name="name" maxlength="50" /></td>
</tr>
<tr>
<td class="formtext">E-mail: </td>
<td class="contactbox"><input type="text" name="email" maxlength="60" /></td>
</tr>
<tr>
<td class="formtext">Subject: </td>
<td class="contactbox">
<select name="subject" size="1">
<option value="opt1">Option 1</option>
<option value="opt2">Option 2</option>
<option value="opt3">Option 3</option>
<option value="Webmaster Services">Webmaster Services</option>
<option value="Search Engine Optimization"> Search Engine Optimization</option>
</select></td></tr>
<tr>
<td class="formtext" valign="top">Message: </td>
<td class="contactbox"><textarea name="message" rows="5" cols="35px"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send" />
<input type="reset" value="Clear" /></td>
</colgroup>
</form>
</table>
The mailform.php file looks like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>E-mail Form</title>
</head>
<body>
<?php
$to = "mail@mywebsite.com";
$headers='From: $email';
if (mail($to, $subject, $message, $email, $headers)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
</body>
</html>
Thank you for any help, I can't find the error.