Jump to content

RESOLVED: Requesting Help - Simple PHP Sendmail Form Problem - Thanks!


LifeInBinary

Recommended Posts

W3Schools Community,I'm trying to get this to send to email, but when you fill out the form and hit send, it just blanks out the form and does nothing - it doesn't send either.'contact.php' uses 'sendmail.php' to send the email - they are both in the root directory.Here is the page live (it's hosted on Linux):http://www.mywilliamsmedia.com/contact.phpsendmail.php

<?php	//CHECK FOR REQUIRED FIELDS	if  ($_REQUEST['name'] != "" AND $_REQUEST['email'] != "" AND $_REQUEST['message'] != "") {				$to	  = 	"info@mywilliamsmedia.com";		$subject = 	"Williams Media Contact - ".$_REQUEST['name'];				$message = 	$_REQUEST['name'];		$message .= "\n".$_REQUEST['phone'];		$message .= "\n".$_REQUEST['email'];		$message .= "\n\n".$_REQUEST['message'];				$headers = 	"From: ".$_REQUEST['email']."\r\n".					"Reply-To: ".$_REQUEST['email']."\r\n" .					"X-Mailer: PHP/".phpversion();		//SEND EMAIL		mail($to, $subject, $message, $headers);				//IF INCLUDING, PROVIDE USER FEEDBACK!		$msg = "Message sent, thank you!";		} else if (isset($_REQUEST['submit'])) {			//IF INCLUDING, PROVIDE USER FEEDBACK!		$msg = "Please make sure all required fields are provided!";	} 		//IF NOT INCLUDING, FORWARD USER BACK TO CONTACT PAGE	//header("Location: contact.html");	//exit();		?>

contact.php

<?php #include "sendmail.php";?><!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>Williams Media - Contact</title><link href="style.css" rel="stylesheet" type="text/css" media="all" /></head><body><div id="body_wrapper_container"><div id="body_wrapper">  <div id="body_header"><a id="williams_media_logo" href="index.html"><h1>Williams Media Logo</h1></a>  <ul id="nav_ul">	<li class="nav_first"><a class="nav_a" href="index.html">home</a></li>	<li class="nav"><a class="nav_a" href="photography.html">photography</a></li>	<li class="nav"><a class="nav_a" href="design.html">design</a></li>	<li class="nav"><a class="nav_a" href="news.html">news</a></li>	<li class="nav"><a class="nav_a" href="services.html">services</a></li>	<li class="nav"><a class="nav_a" href="about.html">about</a></li>	<li class="nav"><a class="nav_a_current" href="contact.php">contact</a></li>  </ul>  </div>    <div id="body_content">	<div id="contact_column_first">		  <p class="p_contact"></p><h4 id="h4_first">jay williams</h4><p></p>	  <ul class="contact_dividers">		<li id="content_divider_first">CEO</li>		<li class="content_divider">Creative Director</li>		<li class="content_divider">Photographer</li>		<li class="content_divider">Designer</li>	  </ul>		  <p class="p_contact"></p><h4>phone</h4><p></p>	  <ul class="contact_dividers">		<li id="content_divider_first">000.000.0000</li>		<li class="content_divider"><a class="contact_phone">M-F</a></li>		<li class="content_divider"><a class="contact_phone">9am-5pm (GMT-5)</a></li>	  </ul>	  	  <p class="p_contact"></p><h4>email</h4><p></p>	  <p class="p_contact"><a class="a_contact" href="mailto:info@mywilliamsmedia.com">info@mywilliamsmedia.com</a></p>	  	  <p class="p_contact"></p><h4>resume</h4><p></p>	  <ul class="contact_dividers">		<li id="content_divider_first"><a class="a_contact" href="resume.pdf">View</a></li>		<li class="content_divider"><a class="a_contact" href="resume.pdf">Download</a></li>	  </ul>	  	  <p class="p_contact"></p><h4>network</h4><p></p>	  <ul id="contact_ul">		<li class="contact_li"><a id="social_linkedin" href="http://www.linkedin.com/profile/view?id=129932354&trk=tab_pro/" target="_blank">Linkedin.com</a></li>		<li class="contact_li"><a id="social_twitter" href="http://twitter.com/#!/Williams_Media/" target="_blank">Twitter.com</a></li>		<li class="contact_li"><a id="social_facebook" href="http://www.facebook.com/WilliamsMedia/" target="_blank">Facebook.com</a></li>		<li class="contact_li"><a id="social_myspace" href="http://www.myspace.com/williams_media/" target="_blank">Myspace.com</a></li>		<li class="contact_li"><a id="social_behance" href="http://www.behance.net/williamsmedia" target="_blank">Behance.com</a></li>		<li id="contact_li_last"><a id="social_vimeo" href="http://www.vimeo.com/mywilliamsmedia" target="_blank">Vimeo.com</a></li>	  </ul>  	</div>	<div class="contact_column">	 <form action="" method="POST" enctype="application/x-www-form-urlencoded" id="contact_form" lang="en" height="0">	  	  <p class="p_contact"><h4 id="h4_first"><label for="name">name *</label></h4></p>	  <p class="p_contact"><input name="name" type="text" id="name" /></p>		  <p class="p_contact"><h4><label for="phone">phone</label></h4></p>	  <p class="p_contact"><input name="phone" id="phone" type="text" /></p>		  <p class="p_contact"><h4><label for="email">email *</label></h4></p>	  <p class="p_contact"><input name="email" id="email" type="text" /></p> 	  <p class="p_contact"><h4><label for="message">message *</label></h4></p><?php if ($msg != "") echo "<p id='feedback'>".$msg."</p>"; ?>	  <p class="p_contact"><textarea name="message" id="message" cols="" rows="11" lang="en"></textarea></p>		  <p class="p_contact_send"><input name="submit" type="submit" id="submit" lang="en" value="send" /></p>	  	  </form>	  	</div>  </div>    <div id="body_footer">	<ul id="validation_ul">	  <li id="valid_xhtml"><a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mywilliamsmedia.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0" target="_blank" class="validation_a_xhtml">W3C Valid XHTML 1.0 Transitional</a></li>	  <li id="valid_css"><a href="http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.mywilliamsmedia.com%2F&profile=css21&usermedium=all&warning=1&vextwarning=&lang=en" target="_blank" class="validation_a_css">W3C Valid CSS 2.1</a></li>	</ul>	<p id="copyright">all content copyright © 2011 • <a id="copyright_williams">williams</a> <a id="copyright_media">media</a> • all rights reserved</p>  </div>  </div></div></body></html>

Thanks for your assistance and support,Jay Williams - Williams Media.

Link to comment
Share on other sites

The action attribute of the <form> element has to point to the file that will process the data. Currently, the page it's pointing to does not process data.

Link to comment
Share on other sites

The action attribute of the <form> element has to point to the file that will process the data. Currently, the page it's pointing to does not process data.
Thank you so much for the reply. I corrected that to
action="sendmail.php"

but now the send button sends me to a blank white page with

http://www.mywilliamsmedia.com/sendmail.php

in the address bar.I'm still searching both files for a fix. Normally I have a developer take care of PHP, I'm pretty limited to XHTML and CSS, but I need to get this working as quickly as possible, so I'm having to figure it out myself this time!Thanks again for your time and assistance,Jay Williams - Williams Media.www.mywilliamsmedia.com

Link to comment
Share on other sites

Thank you so much for the reply. I corrected that to
action="sendmail.php"

but now the send button sends me to a blank white page with

http://www.mywilliamsmedia.com/sendmail.php

in the address bar.I'm still searching both files for a fix. Normally I have a developer take care of PHP, I'm pretty limited to XHTML and CSS, but I need to get this working as quickly as possible, so I'm having to figure it out myself this time!Thanks again for your time and assistance,Jay Williams - Williams Media.www.mywilliamsmedia.com

Yeah, your sendmail page is programmed to do that. It sends the mail and provides you with absolutely no output. Check to see if the mail was received anywhere.
Link to comment
Share on other sites

Yeah, your sendmail page is programmed to do that. It sends the mail and provides you with absolutely no output. Check to see if the mail was received anywhere.
Thank you for the help guys! The form is sending mail now, but is there anything simple that I can do to make sendmail.php show the contact page again instead of just a blank white page?It would be nice if people could fill out the form, hit send, the mail sends, then they are left looking at the contact page again - not a blank white page.How would I go about doing this?Thanks again in advance!
Link to comment
Share on other sites

Just uncomment this part of the code:

	//IF NOT INCLUDING, FORWARD USER BACK TO CONTACT PAGE	//header("Location: contact.html");	//exit();

Link to comment
Share on other sites

Thank you guys so much, I know this was a simple fix, but thanks to your input - it's fixed!Really goes to show how much us designers miss our developers when they aren't available! xDThanks again,Jay Williams - Williams Media.www.mywilliamsmedia.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...