I know this should be simple but it doesn’t work on the server or on my local server.
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (isset($_POST["Submit"])) {
$name = $_POST['name'];
$email = $_POST['eaddress'];
$phone = $_POST['phone'];
$mes = $_POST['query'];
$department = $_POST['Department'];
$to = '[email protected]';
$subject = 'Query';
$message = $name."<br><br>".$email."<br><br> <br><br>".$phone." <br><br>".$department."<br><br>".$mes."<br><br>";
$headers = "From: $email\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
// send if correct.
mail("[email protected]");
echo "Thank you for sending us feedback";
}
?>
Here’s the HTML Form-
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<label>Name<br />
<input name="name" type="text" id="name" size="57" />
<br />
<br />
Telephone (optional)<br />
<input name="phone" type="text" id="phone" size="57" />
<br />
<br />
Email
<br />
<input name="eaddress" type="text" id="eaddress" size="57" />
<br />
<br />
Message
<br />
<textarea name="query" id="query" cols="50" rows="5"></textarea>
<br />
<br />
Department<br />
<select name="Department" size="1" id="Department">
<option selected="selected">Select a department -</option>
<option>Buy a product / Become a customer</option>
<option>Work from home / Become a distrubitor</option>
</select>
<br />
<br />
<input type="submit" name="Submit" id="Submit" value="Submit my request" />
<br />
</label>
</form>
I’ve tried another file with the same code and that works so I can’t see what I’ve done wrong.
Thanks