My PHP form used to send me an email successfully, however, now it displays the echo text as it should on submission of the form, but I don't seem to ever receive the email that I should from it?
PHP code:
<head>
<link rel="stylesheet" type="text/css" title="Main Stylesheet" href="/stylesheet.css" />
<link rel="alternate stylesheet" type="text/css" title="Alternative Stylesheet" href="/alternate%20stylesheet.css" />
</head>
<?php
// pull out the values from the request stream sent by the form
// and store those values into memory variables
$email = $_REQUEST['email'];
$webmail = $_REQUEST['subject'];
$firstName = $_REQUEST['Firstname'];
$lastName = $_REQUEST['Lastname'];
$sex = $_REQUEST['sex'];
$to = 'myemailaddress';
$comment =$_REQUEST['comment'];
$subject =$_REQUEST['subject'];
// New code added for email validation
if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
echo("Email is not valid");
exit();
}
$header = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"';
$header .= ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
$htmlhead = '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">';
$htmlhead .= '<head><title>Feedback Recieved</title>';
$htmlhead .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>';
$htmlbody = '<body>';
// use the variables that store the information sent from the form.
mail($to, $subject,"You have received the following feedback:". $comment, "from " . $firstName . " " . $lastName, "From: $email");
$htmlbody .= "<center><h1>Thank You</h1>";
$htmlbody .= "<p><b>" . $firstName . " " . $lastName ;
$htmlbody .= "</b>, we've recieved an email from your email address: <b>" . $email . "</b>, and will respond as soon as possible!</p></center>";
$htmlbody .= "</body></html>";
// use echo to write all the information out back to the browser
echo $header . $htmlhead . $htmlbody ;
echo '<center>To return, click <a href="/is0502/index.html">here</a>.</center>';
?>
My form page:
<!DOCTYPE HTML>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" title="Main Stylesheet" href="stylesheet.css" />
<link rel="alternate stylesheet" type="text/css" title="Alternative Stylesheet" href="alternate%20stylesheet.css" />
<meta charset="utf-8" />
<title>Contact Us</title>
</head>
<body>
<div id="siteWrapper">
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">Parks</a> <!-- Due to this being a drop-down nav link, the top link is active, but does not actually send the user to a different page, etc. -->
<!-- Code below: creates a new layer onto the lists -->
<ul>
<!-- Code below: makes a dropdown menu for the above menu item -->
<li><a href="disneyland.html">Disney Land</a>
<li><a href="universal.html">Universal</a></li>
<li><a href="buschgardens.html">Busch Gardens</a></li>
<!-- Code below: reverts the following contents of the list to a higher tier -->
</ul>
</li>
<li><a href="#">Restaurants</a>
<ul>
<li><a href="logans.html">Logans</a></li>
<li><a href="outback.html">Outback</a>
<li><a href="perkins.html">Perkins</a></li>
</ul>
<li><a href="statistics.html">Statistics</a></li>
<li><a href="contact_us.html">Contact</a></li>
<li><a href="private/research_paper.html" target="_blank">Research Paper</a></li> <!-- The report page in the website opens in a new tab, enabling the user to return back to the website easily -->
</ul>
</nav>
<div class="imageBanner" title="Beach I visited in Tampa">
<h2>Contact</h2>
</div>
<article>
<p>
I hope that you have found my personal experiences and recommendations helpful on this website, and if you have any questions, please do ask away in the form provided bellow.
</p>
<form action="Scripts/studentinfo.php" method="get" id="studentinfo" onsubmit="return checkform()">
<fieldset>
<legend> Get in Contact </legend>
<label>
Email Address: <input type="text" name="email" value="your email address" />
</label>
<label>
What department would you like to contact?
<select name="subject">
<option value="Complaint">Complaint</option>
<option value="Website Issue">Website Issue</option>
<option value="General Enquiry">General Enquiry</option>
</select>
</label>
<br/>
<label>
First Name: <input type="text" name="Firstname" value="Billy" />
</label>
<label>
Last Name: <input type="text" name="Lastname" value="Pickin" />
</label>
Gender
<br/>
<label>
Male:
<input type="radio" name="sex" value="male" checked="checked" />
</label>
<label>
Female:
<input type="radio" name="sex" value="female" />
</label>
<label>
<textarea rows="4" cols="15" name="comment" value="please tell us what you think"> </textarea>
</label>
<input type="submit" name="submit" value="Submit" />
</fieldset>
</form>
</article>
<footer>
© Billy Pickin 2015. Disclaimer: all expressions on this site are strictly
personal opinions and preferences and may not actually reflect the locations, businesses, etc.
factually.
</footer>
<div id="bottomBarLeft">
<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank">
<img src="/is0502/Photos/cssButton.png" alt="CSS Validation"/>
</a>
</div>
<div id="bottomBarRight">
<a href="http://validator.w3.org/check?uri=referer" target="_blank">
<img src="/is0502/Photos/html5button.png" alt="HTML5 validation"/>
</a>
</div>
</div>
</body>
</html>