PHP contact form sends empty data
Posted
by
Alan Lawlessness
on Stack Overflow
See other posts from Stack Overflow
or by Alan Lawlessness
Published on 2012-07-08T08:25:10Z
Indexed on
2012/07/08
9:15 UTC
Read the original article
Hit count: 183
I am trying to create a HTML5 contact form compatible with computer and mobile devices, when I clicked on send message it jumps into a blank white screen. I do get a email but it contains no information. I am quite new with PHP.
For www.rare1.ca/test:
<!DOCTYPE html>
<html>
<head>
<title>Responsive HTML5/CSS3 template</title>
<meta charset="utf-8" />
<meta name = "viewport" content = "width=device-width, maximum-scale = 1, minimum- scale=1" />
<link rel="stylesheet" type="text/css" href="css/default.css" media="all" />
<link rel="stylesheet" href="css/flexslider.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css' />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>
<script src="js/jquery.flexslider.js"></script>
<script src="js/default.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="pagewidth">
<header id="header">
<div class="center">
<nav id="mainNav">
<ul>
<li class="active"><a href="#pagewidth"><span>gallery</span></a></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li><a href="#contactUs"><span>contact us</span></a></li>
</ul>
</nav>
</div>
</header>
<div id="content">
<section class="row">
<div class="center">
<h1><img src="img/logo.gif" width="142" height="78"></h1>
<strong class="subHeading">Coming soon</strong>
<div class="gallery">
<ul class="slides">
<li><img src="img/img-gallery.jpg" alt="image" /></li>
<li><img src="img/img-gallery2.jpg" alt="image" /></li>
<li><img src="img/img-gallery3.jpg" alt="image" /></li>
</ul>
</div>
<div class="buttons"></div>
</div>
</section>
<section id="contactUs" class="row grey">
<div class="center">
<h1>Contact Us</h1>
<strong class="subHeading">lorem ipsum dolor sit amet, consectetur adipiscing elit</strong>
<div class="columns">
<div class="half">
<form action="sendemail.php" class="form">
<fieldset>
<h2>Feedback form</h2>
<div class="formRow">
<div class="textField"><input type="text" name="Name" id="name" placeholder="Your name ..." /></div>
</div>
<div class="formRow">
<div class="textField"><input type="text" name="Email" id="email" placeholder="Your Email ..." /></div>
</div>
<div class="formRow">
<div class="textField"><textarea name="Message" cols="20" rows="4" placeholder="Your message ..."></textarea> </div>
</div>
<div class="formRow">
<button class="btnSmall btn submit right">
<span>Send Message</span>
</button>
</div>
</fieldset>
</form>
</div>
<div class="half">
<h2>How to find us</h2>
<div id="map">
<div class="imgHolder"><img src="img/map.jpg" alt="google map" /></div>
</div>
</div>
</div>
</div>
</section>
</div>
<footer id="footer">
<div class="center">
</div>
</footer>
</div>
</body>
</html>
<?php
// This is the script for sending email.
// change the email address below to your own email address.
$mailTo = '[email protected]';
$name = htmlspecialchars($_POST['Name']);
$mailFrom = htmlspecialchars($_POST['Email']);
$message_text = htmlspecialchars($_POST['Message']);
$headers = "From: $name <$mailFrom>\n";
$headers .= "Reply-To: $name <$mailFrom>\n";
$message = $message_text;
mail($mailTo, $subject, $message, $headers );
?>
© Stack Overflow or respective owner