WebProgrammerNewb22 Posted October 28, 2010 Share Posted October 28, 2010 Hey guys, I know this is probably a real stupid error, but I've been looking at it for a while and was looking for some advice. I can't figure out why my return home link isn't showing up on my html page. I am making a contact form and have completed my error checking using php. Everything is working except the html for the return home link. I think its because the html openings and closings are out of wack, but i I tried changing it and it gave me an error. Thanks for the help! <body style="color: #F9B984; background-color: #102541"> PHP page: <?php ini_set('display_errors', '0'); //Define Variables. $FirstName = $_GET['FirstNameTextBox']; $LastName = $_GET['LastNameTextBox']; $PhoneNumber = $_GET['PhoneNumberTextBox']; $EmailAddress = $_GET['EmailAddressTextBox']; $Address = $_GET['AddressTextBox']; $City = $_GET['CityTextBox']; $State = $_GET['StateDropDownBox']; $Zip = $_GET['ZipTextBox']; $error1='*Please enter a First Name<br>'; $error2='*Please enter a Last Name<br>'; $error3='*Please enter a Phone Number<br>'; $error4='*Please choose a state<br>'; $error5='*Please enter a valid email address<br>'; $day2 = mktime(0,0,0,date("m"),date("d")+2,date("Y")); $day3 = mktime(0,0,0,date("m"),date("d")+3,date("Y")); $day7 = mktime(0,0,0,date("m"),date("d")+7,date("Y")); //Display errors. if($FirstName=="") {echo $error1; exit;} if($LastName=="") {echo $error2; exit;} if($PhoneNumber=="") {echo $error3; exit;} if($State=="") {echo $error4; exit;} if($EmailAddress=="") {echo $error5; exit;} //Display correct contact date. if($State == "NY") { echo "Hello $FirstName $LastName! Thank you for contacting me. I will get back to you within 2 days, before " .date("d M Y", $day2); exit; } if($State == "NJ") { echo "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 3 days, before " .date("d M Y", $day3); exit; } if($State == "Other") { echo "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 1 week, before " .date("d M Y", $day7); exit; } ?> <p><a href="index.htm"><span class="style1">Return Home</span></a></p> </body> </html> HTML code (even though its probably not needed): <body> <!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 content="en-us" http-equiv="Content-Language" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Contact Me</title> <meta name="description" content="Ways to contact me"/> <style type="text/css"> .style2 { text-align: left; } .style3 { font-family: "Copperplate Gothic Bold"; font-size: xx-large; color: #F8B57E; } .style4 { font-size: xx-large; font-family: "Copperplate Gothic Bold"; letter-spacing: 6pt; color: #F8B57E; } .style5 { text-align: center; } .style6 { text-align: center; margin-top: 8px; } .style19 { color: #F8B57E; font-size: x-large; font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; } .style40 { text-decoration: none; } .style32 { color: #F8B57E; } .style37 { font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; } .style51 { font-size: x-large; font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; } .style52 { text-align: right; font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; color: #F8B57E; } .style53 { text-align: center; margin-top: 8px; font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; font-size: x-large; color: #F8B57E; } .style54 { font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; color: #F8B57E; } </style> <meta content="Different ways to contact me" name="description" /> </head> <body style="color: #FFFFFF; background-color: #102541"> <div id="layer1" class="style2" style="position: relative; width: 1100px; height: 1375px; z-index: 1; margin-bottom: 50px; margin-left: auto; margin-right: auto; margin-top: 50px; border-style: solid; border-color: #F8B57E"> <p class="style5" style="height: 84px"> <br /> <br /> <span class="style4">Jonathan M. Palmieri</span></p> <hr class="style3" noshade="noshade" style="width: 85%; height: 4px; margin-bottom: 0px" /> <p class="style6" style="height: 34px; margin-top: 0px"> <a class="style40" href="index.html"> <span class="style19"> Home</span></a><span class="style19"> | <a class="style40" href="resume.html"><span class="style32">My Resume</span></a> | <a class="style40" href="HobbiesInterests.html"><span class="style32">Hobbies & Interests</span></a> | <a class="style40" href="WorkInterests.html"><span class="style32">Work Interests</span></a> | <a class="style40" href="CoursesTaken.html"> <span class="style32">Courses Taken</span></a> | </span> <span class="style51"> Contact Me</span></p> <p class="style6" style="height: 34px; margin-top: 0px"> </p> <p class="style53" style="height: 34px; margin-top: 0px"> Contact Me</p> <table style="width: 100%"> <tr> <td class="style5"> <form action="AddContact.php" method="get"> <span class="style54">* Indicates a required field</span><br /> <table style="width: 100%"> <tr> <td class="style52" style="width: 504px">First Name</td> <td class="style2"><input name="FirstNameTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">Last Name</td> <td class="style2"><input name="LastNameTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">Phone Number</td> <td class="style2"><input name="PhoneNumberTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">Email Address</td> <td class="style2"><input name="EmailAddressTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">Address</td> <td class="style2"><input name="AddressTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">City</td> <td class="style2"><input name="CityTextBox" type="text" /></td> </tr> <tr> <td class="style52" style="width: 504px">State</td> <td class="style2"><select name="StateDropDownBox"> <option>NJ</option> <option>NY</option> <option>Other</option> </select></td> </tr> <tr> <td class="style52" style="width: 504px">Zip</td> <td class="style2"><input name="ZipTextBox" type="text" /></td> </tr> </table> <input name="SubmitButton" type="submit" value="Submit" /><br /> <br /> <br /> <br /> </form> </td> </tr> <tr> <td> </td> </tr> </table> <p> <span class="style32"><span class="style37"> </span></span></p> <p> </p> <p> </p> <p> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"> </p> <p class="style5"><span class="style32"><span class="style37">Privacy Policy | Terms of Use | Contact Me</span><br class="style37" /> <span class="style37"> Website Designed and Developed by Jonathan Palmieri</span><br class="style37" /> <br class="style37" /> <span class="style37"> Copyright © 2010</span></span></p> </div> </body> </html></body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/ Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2010 Share Posted October 28, 2010 Does the html show up in View Source? Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127377 Share on other sites More sharing options...
WebProgrammerNewb22 Posted October 28, 2010 Author Share Posted October 28, 2010 The html is for the actual contact form. That page works fine. I just threw that code in as well. The php page is the problem. The only thing I cannot get to show up is that return home link at the bottom. It just shows up with the error messag and the user has to hit back. Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127380 Share on other sites More sharing options...
DavidAM Posted October 28, 2010 Share Posted October 28, 2010 The only thing I cannot get to show up is that return home link at the bottom. It just shows up with the error messag and the user has to hit back. //Display errors. if($FirstName=="") {echo $error1; exit;} if($LastName=="") {echo $error2; exit;} The exit call, exits the script. Lights out, close the door, goodbye! NOTHING after the exit is executed. (This means the link at the bottom of the script file is never sent to the browser.) If you have to have the exits, move your link up to the top of the page. Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127383 Share on other sites More sharing options...
WebProgrammerNewb22 Posted October 28, 2010 Author Share Posted October 28, 2010 it did not work wihtout the exits.. is there anyway to get rid of them and make it work?? i really would like the return home at the bottom.. thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127386 Share on other sites More sharing options...
Pikachu2000 Posted October 28, 2010 Share Posted October 28, 2010 I can't say I'd consider this the ideal solution, but one way to deal with it as a down and dirty quick-fix would be to store the link in a variable, and echo it just before any exit(); call. $link = '<p><a href="index.htm"><span class="style1">Return Home</span></a></p></body></html>'; // Then echo it before each exit();. if($FirstName=="") {echo "$error1<br>$link"; exit;} Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127388 Share on other sites More sharing options...
DavidAM Posted October 28, 2010 Share Posted October 28, 2010 Collect the messages to be output in an array, and output them at the end. // Array to collect messages $messages = array(); //Display errors. if($FirstName=="") {$messages[] = $error1; } if($LastName=="") {$messages[] = $error2; } if($PhoneNumber=="") {$messages[] = $error3; } if($State=="") {$messages[] = $error4; } if($EmailAddress=="") {$messages[] = $error5; } // Don't do this part unless we have no errors if (empty($messages)) { //Display correct contact date. if($State == "NY") { $messages[] = "Hello $FirstName $LastName! Thank you for contacting me. I will get back to you within 2 days, before " .date("d M Y", $day2); } if($State == "NJ") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 3 days, before " .date("d M Y", $day3); } if($State == "Other") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 1 week, before " .date("d M Y", $day7); } } // END if empty($messages echo implode('<BR>', $messages); ?> <p><a href="index.htm"><span class="style1">Return Home</span></a></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127396 Share on other sites More sharing options...
WebProgrammerNewb22 Posted October 28, 2010 Author Share Posted October 28, 2010 Collect the messages to be output in an array, and output them at the end. // Array to collect messages $messages = array(); //Display errors. if($FirstName=="") {$messages[] = $error1; } if($LastName=="") {$messages[] = $error2; } if($PhoneNumber=="") {$messages[] = $error3; } if($State=="") {$messages[] = $error4; } if($EmailAddress=="") {$messages[] = $error5; } // Don't do this part unless we have no errors if (empty($messages)) { //Display correct contact date. if($State == "NY") { $messages[] = "Hello $FirstName $LastName! Thank you for contacting me. I will get back to you within 2 days, before " .date("d M Y", $day2); } if($State == "NJ") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 3 days, before " .date("d M Y", $day3); } if($State == "Other") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 1 week, before " .date("d M Y", $day7); } } // END if empty($messages echo implode('<BR>', $messages); ?> <p><a href="index.htm"><span class="style1">Return Home</span></a></p> </body> </html> Thanks a lot man! That worked perfectly! Any idea how to make sure that the email address is a valid email address?? Also, I think I need to make sure the phone number is an actual phone number. What would be the PHP for this validation? Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1127406 Share on other sites More sharing options...
DavidAM Posted October 30, 2010 Share Posted October 30, 2010 See the PHP manual (if you are running 5.2 or later) filter_var() You can search this site or Google. I have seen that question answered many times. Quote Link to comment https://forums.phpfreaks.com/topic/217067-return-home-link-not-showing/#findComment-1128217 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.