hoku_007 Posted December 14, 2014 Share Posted December 14, 2014 <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Contact Us</title><meta name="keywords" content="" /><meta name="description" content="" /><!--Template 2043 Pinky Flowhttp://www.tooplate.com/view/2043-pinky-flow--><link href="css/tooplate_style.css" rel="stylesheet" type="text/css" /><link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" /><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/ddsmoothmenu.js">/************************************************ Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)* This notice MUST stay intact for legal use* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code***********************************************/</script><script type="text/javascript">ddsmoothmenu.init({ mainmenuid: "tooplate_menu", //menu DIV id orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v" classname: 'ddsmoothmenu', //class added to menu's outer DIV //customtheme: ["#1c5a80", "#18374a"], contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]})</script><link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" /> <!-- Arquivos utilizados pelo jQuery lightBox plugin --> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" /> <!-- / fim dos arquivos utilizados pelo jQuery lightBox plugin --> <!-- Ativando o jQuery lightBox plugin --> <script type="text/javascript"> $(function() { $('#map a').lightBox(); }); </script></head><body><div id="tooplate_wrapper"> <div id="tooplate_header"> <div id="site_title"><h1><a href="index.html">Rubi Noodle Studios</a></h1></div> <div id="tooplate_menu" class="ddsmoothmenu"> <ul> <li><a href="index.html" class="selected"><span></span>Home</a></li> <li><a href="gallery.html"><span></span>Galleries</a> <ul> <li><a href="families.html">Families</a></li> <li><a href="children.html">Children</a></li> <li><a href="graduates.html">Graduates</a></li> <li><a href="engagement.html">Engagement</a></li> <li><a href="weddings.html">Weddings</a></li> <li><a href="maternity.html">Maternity</a></li> </ul> </li> <li><a href="information.html"><span></span>Information</a> <ul> <li><a href="announcements.html">Graduation Announcements</a></li> <li><a href="pricing.html">Pricing</a></li> <li><a href="hints.html">Helpful Hints</a></li> </ul> </li> <li><a href="client.html"><span></span>Client Viewing</a></li> <li><a href="contact.html" class="selected"><span></span>Contact</a></li> </ul> <br style="clear: left" /> </div> <!-- end of tooplate_menu --> <div id="tooplate_main"> <div id="tooplate_content"> <h2>Contact Information</h2> <p><em>Have a question about a session or want to set up a session? Please feel free to contact me.</em></p> <div class="h30"></div> <div class="col_w420 float_l"> <div id="contact_form"> <h3>Quick Contact Form</h3> <?php if (isset($_POST['Submit'])) { if ($_POST['author'] != "") { $_POST['author'] = filter_var($_POST['author'], FILTER_SANITIZE_STRING); if ($_POST['author'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if ($_POST['subject'] != "") { $email = filter_var($_POST['subject'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= 'Please enter a subject.<br/></br>'; } } else { $errors .= 'Please enter your subject.<br/>'; } if ($_POST['text'] != "") { $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING); if ($_POST['text'] == "") { $errors .= 'Please enter a message to send.<br/>'; } } else { $errors .= 'Please enter a message to send.<br/>'; } if (!$errors) { $first_name=$_POST['author']; $email_address=$_POST['email']; $message=$_POST['text']; mail("myemail@yahoo.com","$subject", $message,"From: $first_name <$email_address>"); header("Location:contact.php?thankyou"); exit(); } else { echo '<div style="color: red">' . $errors . '<br/></div>'; } } ?> <?PHP//Then outside the processing script add If (isset($_GET['thankyou'])){echo "Thank you for your email!<br/><br/>";}?> <form method="post" name="form1" action="contact.php" /> <label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/> <div class="cleaner h10"></div> <label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" /> <div class="cleaner h10"></div> <label for="subject">Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" /> <div class="cleaner h10"></div> <label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required"value="<?php echo $_POST['text']; ?>" ></textarea> <div class="cleaner h10"></div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> </div> </div> <div class="col_w420 float_r"> <h3>Location</h3> <div id="map"> <a href="images/map_big.png" title="Our Location"> <img width="300" height="150" src="images/map_thumb.png" alt="Location" class="image_wrapper" /> </a> </div> <div class="cleaner h30"></div> <h3>Mailing Address</h3> <h6>Address</h6> Address <br /> <br /> <br /><br /> <strong>Phone:</strong> 020-054-1520<br /> <strong>Email:</strong> <a href="mailto:info@company.com">info@company.com</a> </div> <div class="cleaner"></div> </div> <div class="cleaner"></div> </div> <!-- end of tooplate_main --> <div id="tooplate_footer"> Copyright © 2014 <a href="index.html">Studios</a> | Design: <a href="http://www.tooplate.com">tooplate</a> <div class="cleaner"></div> </div> </div> <!-- end of forever header --></div> <!-- end of forever wrapper --></body></html> My contact form doesn't send emails, not sure what I did wrong, but any help is much appreciated. Link to comment Share on other sites More sharing options...
Ingolme Posted December 14, 2014 Share Posted December 14, 2014 Are you getting any error messages? If not, then there is another procedure you must follow. The mail() function returns a boolean value that tells you whether the mail was accepted for delivery or not, check whether it is true or false before showing a success message: $success = mail( ... );if($success) { // Show success message} else { // Show failure message} Are you testing this from your own home machine? Most testing server software does not come with a mail server installed, so you'll need to test in a real server environment to make sure your mailing form works. Unrelated to the problem, I recommend you put all your form handling logic at the very start of the page before the <!DOCTYPE> declaration. If there's anything that needs to be printed onto the page, just store it in a variable and print the variable wherever it needs to be on the page. Headers should be sent before any of the content of the page, but from my experience this year it seems newer versions of PHP have been prepared to handle late headers without any error messages. Link to comment Share on other sites More sharing options...
hoku_007 Posted December 14, 2014 Author Share Posted December 14, 2014 No, I am testing it on an actual server. I just made a few changes to my code, and the error I get is parse error : syntax error, unexpected '<' on line 1. Link to comment Share on other sites More sharing options...
Ingolme Posted December 14, 2014 Share Posted December 14, 2014 That error does not match the code you're showing. There's no PHP on line 1. There is an error on this line: <?PHP//Then outside the processing script add If (isset($_GET['thankyou'])){echo "Thank you for your email!<br/><br/>";}?> PHP is case sensitive, "If" is different than "if". The letters "PHP" should be lowercase as well. Link to comment Share on other sites More sharing options...
hoku_007 Posted December 15, 2014 Author Share Posted December 15, 2014 <?php if (isset($_POST['submit'])) { if ($_POST['author'] != "") { $_POST['author'] = filter_var($_POST['author'], FILTER_SANITIZE_STRING); if ($_POST['author'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if ($_POST['subject'] != "") { $email = filter_var($_POST['subject'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= 'Please enter a subject.<br/></br>'; } } else { $errors .= 'Please enter your subject.<br/>'; } if ($_POST['text'] != "") { $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING); if ($_POST['text'] == "") { $errors .= 'Please enter a message to send.<br/>'; } } else { $errors .= 'Please enter a message to send.<br/>'; } if (!$errors) { $author=$_POST['author']; $email=$_POST['email']; $text=$_POST['text']; mail("myemail@yahoo.com","$subject", $text,"From: $author <$email>"); header("Location:contact.php?thankyou"); exit(); } else { echo '<div style="color: red">' . $errors . '<br/></div>'; } } ?> <?php//Then outside the processing script add if (isset($_GET['thankyou'])){echo "Thank you for your email!<br/><br/>";}?> <form method="post" name="form1" action="contact.php" /> <label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/> <div class="cleaner h10"></div> <label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" /> <div class="cleaner h10"></div> <label for="subject">* Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" /> <div class="cleaner h10"></div> <label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required" value="<?php echo $_POST['text']; ?>" ></textarea> <div class="cleaner h10"> </div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> I went back and fixed a few more errors. Now it kind of works. When I fill out the form completely, I get the error message saying that "subject is required." (which is one the errors messages that I am using). Link to comment Share on other sites More sharing options...
hoku_007 Posted December 15, 2014 Author Share Posted December 15, 2014 if ($_POST['subject'] != "") { $_POST['subject'] = filter_var($_POST['subject'], FILTER_SANITIZE_STRING); if ($_POST['subject'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your subject.<br/>'; } I think I know what I am missing: Link to comment Share on other sites More sharing options...
hoku_007 Posted December 15, 2014 Author Share Posted December 15, 2014 $subject=$_POST['subject'] Also, I am missing : Link to comment Share on other sites More sharing options...
hoku_007 Posted December 15, 2014 Author Share Posted December 15, 2014 <?php if (isset($_POST['submit'])) { if ($_POST['author'] != "") { $_POST['author'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING); if ($_POST['author'] == "") { $errors .= 'Please enter a valid name.<br/><br/>'; } } else { $errors .= 'Please enter your name.<br/>'; } if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if ($_POST['text'] != "") { $_POST['text'] = filter_var($_POST['text'], FILTER_SANITIZE_STRING); if ($_POST['text'] == "") { $errors .= 'Please enter a message to send.<br/>'; } } else { $errors .= 'Please enter a message to send.<br/>'; } if (!$errors) { $first_name=$_POST['author']; $email_address=$_POST['email']; $subject = $_POST['subject'] $text=$_POST['text']; mail("myemailaddress@yahoo.com","$subject", $text,"From: $first_name <$email_address>"); header("Location:contact.php?thankyou"); exit(); } else { echo '<div style="color: red">' . $errors . '<br/></div>'; } } ?> <?php//Then outside the processing script add If (isset($_GET['thankyou'])){echo "Thank you for your email!<br/><br/>";}?> <form method="post" name="form1" action="contact.php" /> <label for="author">* Name:</label> <input type="text" id="author" name="author" class="required input_field" value="<?php echo $_POST['author']; ?>"/> <div class="cleaner h10"></div> <label for="email">* Email:</label> <input type="text" class="validate-email required input_field" name="email" id="email" value="<?php echo $_POST['email']; ?>" /> <div class="cleaner h10"></div> <label for="subject">* Subject:</label> <input type="text" class="validate-subject required input_field" name="subject" id="subject" value="<?php echo $_POST['subject']; ?>" /> <div class="cleaner h10"></div> <label for="text">* Message:</label> <textarea id="text" name="text" rows="0" cols="0" class="required" value="<?php echo $_POST['text']; ?>" ></textarea> <div class="cleaner h10"> </div> <input type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l" /> <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" /> </form> I went back and made a few changes, now my webserver gives my this error when I test it on there: Parse error :syntax error, unexpected T_VARIABLE in home/a75600006/public_html/New folder(7)/contact.php on line 140. Link to comment Share on other sites More sharing options...
hoku_007 Posted December 15, 2014 Author Share Posted December 15, 2014 Never mind, I figured out that I Was missing a semicolon. Now that I corrected it, my form still wont send me and email when I fill out the form correctly. Link to comment Share on other sites More sharing options...
Ingolme Posted December 15, 2014 Share Posted December 15, 2014 Check to see if the mail was successfully sent: $success = mail( ... );if($success) { // Show success message} else { // Show failure message} Link to comment Share on other sites More sharing options...
hoku_007 Posted December 19, 2014 Author Share Posted December 19, 2014 What does mean, when I upload my file and when I view it on my webserver the php code shows up in the name, subject, and email fields? Link to comment Share on other sites More sharing options...
Ingolme Posted December 19, 2014 Share Posted December 19, 2014 That means your server isn't executing the PHP. Make sure your file has a .php extension and that the server actually supports PHP. Link to comment Share on other sites More sharing options...
hoku_007 Posted December 19, 2014 Author Share Posted December 19, 2014 I've made sure that I am using the .php extension and my server supports php 5.2.12. Could it be that I am coding my contact form wrong? I found a PHP code checker online and it even tells me that there are no errors. Link to comment Share on other sites More sharing options...
Ingolme Posted December 19, 2014 Share Posted December 19, 2014 The server is not executing the PHP. That's all I can tell you from the symptoms you described. Check the URL in the address bar and confirm it's .php and not, perhaps, .php.html Link to comment Share on other sites More sharing options...
hoku_007 Posted December 19, 2014 Author Share Posted December 19, 2014 I went back and re-did my file and uploaded it. My address bar says contact.php and now I don't see the code in my fields. However, when I run it, it works like it suppose to I just don't receive the email. Link to comment Share on other sites More sharing options...
Ingolme Posted December 19, 2014 Share Posted December 19, 2014 Did you check the return value of the mail() function to see if it was true or false? Link to comment Share on other sites More sharing options...
hoku_007 Posted December 19, 2014 Author Share Posted December 19, 2014 <?php $to = "somebody@example.com"; $subject = "My subject"; $txt = "Hello world!"; $headers = "From: webmaster@example.com" . "rn" . "CC: somebodyelse@example.com"; mail($to,$subject,$txt,$headers); ?> I don't think my webhost allows to send email via the html because I've tried the following php code and I still got nothing. I placed the php above the <!DOCTYPE html> and nothing. Link to comment Share on other sites More sharing options...
Ingolme Posted December 19, 2014 Share Posted December 19, 2014 Like I mentioned earlier, check the return value of the mail() function to see whether it succeeded or not: $success = mail($to,$subject,$txt,$headers);if($success) { // Show success message} else { // Show failure message} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now