Hi I'm mainly a website designer and I thought I would put a contact form on my new portfolio website.
With the help of a friend who had already added a contact form to her site.
we cant see an issue with the code but it is refusing to send emails to my website. And the echo messages wont appear on the website.
I was wondering if any one could help!
PHP Code:
<?php //COLLECT POST data $formValue=array(); foreach ($_POST as $key => $value) { $formValue[$key] = strip_tags($value); }
if(isset($_GET['sendmail'])){
//Check for empty fields
if($formValue['name']==""){ $message="Sorry! I need to know your name. Please complete all fields."; header("Location: contact.php?message=$message") ; }else if($formValue['email']==""){ $message="Sorry! I need your email address. Please complete all fields."; header("Location: contact.php?message=$message"); }else if($formValue['comment']==""){ $message="I think you forgot to leave me a message!?"; header("Location: contact.php?message=$message"); }else{
$name = $_POST['name'] ; $email = $_POST['email'] ; $comment = $_POST['comment'] ;
$subject = "Website Comment";
$from = "$name \n $email";
$body = "$comment";
ini_set("sendmail_from", "victoriahogg@hotmail.com"); mail('victoriahogg@hotmail.com', $subject, $body, $from);
$message = "Thank you for your message" ; header("Location: thankyou.php?message=$message"); } }
?>
<!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" /> <link rel="stylesheet" type="text/css" href="style_contact.css"> <title>Victoriahogg.com</title>
</head> <body onload="MM_preloadImages('images/rollover_home.gif','images/rollover_about me.gif','images/rollover_work.gif','images/rollover_contact.gif')">
<div id="wrapper">
<div id="nav"> <a href="index.html"><img src="images/home.gif" alt="Home" name="Home" width="192" height="48" border="0" id="Home" /></a> <a href="about.html"><img src="images/about me.gif" alt="About Me" name="About Me" width="193" height="48" border="0" id="About Me" /></a> <a href="work.html"><img src="images/work.gif" alt="Work" name="Work" width="194" height="48" border="0" id="Work" /></a> <a href="contact.html"><img src="images/contact.gif" alt="Contact Me" name="Contact" width="195" height="48" border="0" id="Contact" /></a></div>
<div id="banner"> </div>
<div id="folder">
<div id="content">
<h1><center>Contact me.</center></h1> <blockquote> <form id="contactForm" action="contact.php?sendmail=1" method="post" name="contactForm"> <input type="hidden" name="about" value="Website Comment"> <label>Name: </label> <input class="inputField" type="text" name="name" size="35"><br /><br />
<label>Email:</label> <input class="inputField" type="text" name="email" size="35"><br /><br /> <label>Comments:</label><br /> <textarea class="textArea" name="comment" rows="9" cols="35"></textarea> <br /> <br />
<input class="sendButton" name="submit" type="submit" value="Submit" title="Submit"/> </form> <p><?php echo $message ;?></p> </blockquote> </div> <div id="footer"> (c) Victoria Hogg 2010</div> </div> </div>
</body> </html>
And this is the thank you form.
PHP Code:
<?php //COLLECT POST data $formValue=array(); foreach ($_POST as $key => $value) { $formValue[$key] = strip_tags($value); }
if(isset($_GET['sendmail'])){
//Check for empty fields
if($formValue['name']==""){ $message="Sorry! I need to know your name. Please complete all fields."; header("Location: contact.php?message=$message") ; }else if($formValue['email']==""){ $message="Sorry! I need your email address. Please complete all fields."; header("Location: contact.php?message=$message"); }else if($formValue['comment']==""){ $message="I think you forgot to leave me a message!?"; header("Location: contact.php?message=$message"); }else{
$name = $_POST['name'] ; $email = $_POST['email'] ; $comment = $_POST['comment'] ;
$subject = "Website Comment";
$from = "$name \n $email";
$body = "$comment";
ini_set("sendmail_from", "victoriahogg@hotmail.com"); mail('victoriahogg@hotmail.com', $subject, $body, $from);
$message = "Thank you for your message" ; header("Location: thankyou.php?message=$message"); } }
?>
<!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" /> <link rel="stylesheet" type="text/css" href="style_contact.css"> <title>Victoriahogg.com</title>
</head> <body onload="MM_preloadImages('images/rollover_home.gif','images/rollover_about me.gif','images/rollover_work.gif','images/rollover_contact.gif')">
<div id="wrapper">
<div id="nav"> <a href="index.html"><img src="images/home.gif" alt="Home" name="Home" width="192" height="48" border="0" id="Home" /></a> <a href="about.html"><img src="images/about me.gif" alt="About Me" name="About Me" width="193" height="48" border="0" id="About Me" /></a> <a href="work.html"><img src="images/work.gif" alt="Work" name="Work" width="194" height="48" border="0" id="Work" /></a> <a href="contact.html"><img src="images/contact.gif" alt="Contact Me" name="Contact" width="195" height="48" border="0" id="Contact" /></a></div>
<div id="banner"> </div>
<div id="folder">
<div id="content">
<h1><center>Contact me.</center></h1> <blockquote> <p>Thank you for your Message. I will try and get back to you as soon as possible. <?php echo $message ;?></p> </blockquote> </div> <div id="footer"> (c) Victoria Hogg 2010</div> </div> </div>
</body> </html>
Thank you in advance.
|