Join Login


New Hosting Plans On Sale now at GoDaddy.com!
 html/PHP form not showing up
 by lstumpf - May 03, 2012

Hey all. Much like some other posters in this forum I tried following the youtube tutorial on how to create an html contact form that uses PHP to submit that form as an email. I'm going to paste my code below but also wondered if I was maybe saving files in the wrong place. I currently have all files saved in my htdocs folder WITHIN my MAMP folder. MAMP is on and connected and tested.
Please Help!
Thanks

...here's my code:

<?php
if ($_POST['parse_var'] == "contactform") {

$emailTitle = 'New Message from your Website';
$yourEmail = 'xxxxxxxxx@gmail.com';

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$messageField = $_POST['message'];

$body = <<<EOD
<br><hr><br>
Email: $emailField <br />
Name: $nameField <br />
Message: $messageField <br />
EOD;

$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail("$yourEmail", "$emailTitle", "$body", "$headers");
$sent = "Thank Your message has been sent.";

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contact_Form</title>
</head>

<body>
<table width="400" border="1" cellspacing="50" cellpadding="0">
<tr>
<td align="left">contact me
<br /><br />
<form id="contactform" name="contactform" method="post" action="contact_form.php">
<table width="100%" border="0" cellpadding="3">
<tr>
<td width="25%" align="right">name:</td>
<td width="75%"><label for="name"></label>
<input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$nameField"; ?>" /></td>
</tr>
<tr>
<td align="right">email:</td>
<td><label for="email"></label>
<input type="text" name="email" id="email" maxlength="50" size="30" value="<?php print "$emailField"; ?>"/>
</label></td>
</tr>
<tr>
<td align="right">message:
<td><label>
<textarea name="message" id="message" cols="40" rows="5"><?php print "$messageField"; ?></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="blue" align="right"><label>
<input type="reset" name="reset" id="reset" value="Reset" />
<input type="hidden" name="parse_var" id="parse_var" value="contactform" />
<input type="submit" name="submit" id="submit" value="Submit" />
</label></td>
</tr>
<tr>
<td colspan="2"><?php print "$sent"; ?></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>


lstumpf
United States
Posts:1
Joined:May 03, 2012
  
Home About Contact Forum Youtube Privacy Policy
Copyright © 2009-2011 RiverCityGraphix.All Rights Reserved.