help with php code
Hi,
I am a novice, but trying to learn and I am ask for some help if anyone can. I have created a site but it is not the final site, just a draft. www.railwaychaplain.net
I have created a page with a contact form www.railwaychaplain.net/contact.php
I have placed the code I have used below. every thing looks ok for a simple form, but no message is received when 'Submit' is selected.
Would anyone please be able to correct whatever it is I have done wrong?
Thank you for your help.
Kind regards, Liam
--------
<?php
/*subject for RailHope email*/
$emailSubject = 'RailHope email form';
$emailRecipient = 'liam.johnston@railwaymission.org';
/* Data variables */
$firstnameField = $_POST['firstname'];
$lastnameField = $_POST['lastname'];
$youremailField = $_POST['youremail'];
$subjectField = $_POST['subject'];
$body = <<<EOD
<br><hr><br>
firstname: $firstname <br>
lastname: $lastname <br>
youremail: $youremail <br>
subject: $subject <br>
EOD;
$headers = "From: $youremail\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($emailRecipient, $emailSubject, $body, $headers);
/* Results renderd as HTML */
$theResults = <<<EOD
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RailHope International</title>
<link href="WebsiteAssets/styles/blogPostStyle.css" rel="stylesheet" type="text/css">
<script>var __adobewebfontsappname__="dreamweaver"</script>
<script src="http://use.edgefonts.net/montserrat:n4:default;source-sans-pro:n2:default.js" type="text/javascript"></script>
</head>
<body><div id="mainwrapper">
<header>
<div id="logo"><img src="WebsiteAssets/images/RailHope-International-3D-shadow.png" width="198" height="90" alt=""/><!-- <img src="logoImage.png" alt="sample logo"> --><!-- Company Logo text --> </div>
<nav><a href="index.html"> Home</a> <a href="events.html"> Events</a> <a href="statmentoffaith.html"> Statement of Faith</a> <a href="contact.html" title="Link">Contact</a></nav>
</header>
<div id="content">
<div class="notOnDesktop">
<!-- This search box is displayed only in mobile and tablet laouts and not in desktop layouts -->
<input type="text" placeholder="Search">
</div>
<section id="mainContent">
<h1>Contact Us</h1>
<h3>Living Life Through Faith in God</h3>
<div id="bannerImage"><img src="WebsiteAssets/images/Lunteren-1000-300Crop.png" alt=""/></div>
<p> </p>
<aside id="authorInfo">
<p>
<div class="container">
<form action="contact.php" method="post" target="_self">
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name..">
<label for="lname">Last Name</label>
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
<label for="lname">Your E-mail</label>
<input type="text" id="email" name="youremail" placeholder="Your e-mail..">
<textarea id="subject" name="subject" placeholder="Write something.." style="height:200px" ></textarea>
<input type="submit" value="Submit">
</form>
</div>
</p>
</aside>
</section>
<section id="sidebar">
<script async src="https://cse.google.com/cse.js?cx=011950308938588625035:ajfe2qwptc4"></script>
<div class="gcse-search"></div>
<div id="adimage"><img src="WebsiteAssets/images/300-300Crop-Three-with-train.jpg" alt=""/></div>
<nav>
<ul>
<li><img src="WebsiteAssets/images/Switzerland.jpg" width="27" height="18" alt=""/><a href="switzerland.html" target=""> RailHope Switzerland</a></li>
<li><img src="WebsiteAssets/images/Germany.png" width="27" height="18" alt=""/><a href="germany.html" target=""> RailHope Germany</a></li>
<li><img src="WebsiteAssets/images/Austria.jpg" width="27" height="18" alt=""/><a href="austria.html" title="Link"> RailHope Austria</a></li>
<li><img src="WebsiteAssets/images/America.jpg" width="27" height="18" alt=""/><a href="america.html" title="Link"> RailHope America</a></li>
<li><img src="WebsiteAssets/images/Estonia.png" width="27" height="18" alt=""/><a href="estonia.html" title="Link"> RailHope Estonia</a></li>
<li><img src="WebsiteAssets/images/Finland.png" width="27" height="18" alt=""/><a href="finland.html" title="Link"> RailHope Finland</a></li>
<li><img src="WebsiteAssets/images/India.png" width="27" height="18" alt=""/><a href="india.html" title="Link"> RailHope India</a></li>
<li><img src="WebsiteAssets/images/Netherlands.png" width="27" height="18" alt=""/><a href="netherlands.html" title="Link"> RailHope Netherlands</a></li>
<li><img src="WebsiteAssets/images/Norway.png" width="27" height="18" alt=""/><a href="norway.html" title="Link"> RailHope Norway</a></li>
<li><img src="WebsiteAssets/images/Singapore.png" width="27" height="18" alt=""/><a href="singapore.html" title="Link"> RailHope Singapore</a></li>
<li><img src="WebsiteAssets/images/South-Africa.png" width="27" height="18" alt=""/><a href="south-africa.html" title="Link"> RailHope South-Africa</a></li>
<li><img src="WebsiteAssets/images/Great Britain.png" width="27" height="18" alt=""/><a href="greatbritain.html"> Railway Mission</a><a href="Britsh Railway Mission"></a></li>
</ul>
</nav>
</section>
<footer>
<!--************************************************************************
Footer starts here
****************************************************************************-->
<article>
<h3><a href="board.html"><strong>Board Info</strong></a></h3>
<p data_temp_dwid="1">The board of RailHope International works is the administrative body of the organisation, the Chair of the Board is the International President: Ulrich Berger</p>
</article>
<article>
<h3><a href="board.html">General Assembly Info</a></h3>
<p>The highest decision-making body of the IRM is the General Assembly. All present representatives of the national associations are entitlet to vote.</p>
</article>
</footer>
</div>
<div id="footerbar"><!-- Small footerbar at the bottom --></div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
