virtual Posted March 5, 2010 Report Share Posted March 5, 2010 (edited) I have a php code that does not show the footer unless the message is correct and gets sent. If there is an error in filling in the fields the code does not show the footer. I know I have to put an 'else' statement in there, but I have no idea how. If there is any bad code in there please feel free to correct it, I am a PHP idiot.... $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $phone = $_POST['phone']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "Please hit the Back buttonPlease Enter a valid e-mail address\n"; $badinput = "Your email was NOT sent\n"; echo $badinput; die (" Use browser back button !"); } if(empty($visitor) || empty($visitormail) || empty($phone) || empty($notes )) { echo "Please hit the Back button - fill in all fields\n"; die (" Use browser back button !"); } THIS IS WHERE I NEED THE STATEMENT TO MAKE IT GO TO THE END AND THEN READ THE FOOTER $todayis = date("l, F j, Y, g:i a") ; $phone = $phone; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Message: $notes \n From: $visitor ($visitormail)\n Referral : tenerifebusinessinformation \n "; $from = "From: $visitormail\r\n"; mail("lynne.mb@gmail.com", $subject, $message, $from); ?> Thank you for expressing your interest in Tenerife Business Information. We look forward to speaking with you and helping you get started on your new or existing project. Below is the information you entered on our form, we will contact you soon. Once again Thank You and we look forward to working with you. Phone Number: Message: ", $notes); echo $notesout; ?> Return to Home Page Edited March 5, 2010 by virtual Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 5, 2010 Report Share Posted March 5, 2010 I'm not quite sure what your footer contains... but if you want to show it after an error, you'd need to place it before the two die (" Use browser back button !"); statements, since after the die() the script ends and none of the rest of the code gets looked at. Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 OK I'll try that. Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 Just to be sure, so I have to put the closing content div, message div and then the footer div in each of the error messages before the "die"? Then also leave it at the end so that when the script reads correctly it will close the divs and add the footer? Ben I just got the 180 second wait thing again... Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 Well, that didn't work. Can you please insert in my code what I'm supposed to do, like I was a 2 year old, I really don't understand this PHP stuff. Thanks Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 5, 2010 Report Share Posted March 5, 2010 I'll need to look at this in a bit more detail later today... Where exactly is the code that contains your footer? Is it in the code you provided in the first post? (If I understand it correctly, the code you're showing in your first post only includes the content div, not anything else?) Are you including the code you showed in your first post within an include? for example Main file: -- include header -- include content (code in your first post) -- include footer If so, using die() may prevent the footer div from being included, so it's possible using die() isn't a good choice here and it should be removed. Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 No I'm not yet using includes as I am still building out the site. It actually doesn't matter too much if it doesn't show the footer on the error message but it is not closing out the message and content div either which is more important as the design looks incomplete. That's why I thought an "if else" would be better, but as I said I have taken 3 classes in PHP and never finished any of them, I'm a complete right brainer.... Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 5, 2010 Report Share Posted March 5, 2010 Where exactly is the code that contains your footer? Is it in the code you provided in the first post? If so, can you let me know which parts of that code display your footer? (If I understand it correctly, the code you're showing in your first post only includes the content div, not anything else?) Just repeating the question... Quote Link to comment Share on other sites More sharing options...
PicnicTutorials Posted March 5, 2010 Report Share Posted March 5, 2010 Could you not just have two different pages - your success page and error page? Would accomplish the same? Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 @Ben, forget about the footer, how do I close the divs that are contained in the code I posted after each error message? @Eric, if I knew how to do that I wouldn't be asking daft questions here. I'm just using a premade script from here http://www.ibdhost.com/contact/ Quote Link to comment Share on other sites More sharing options...
PicnicTutorials Posted March 5, 2010 Report Share Posted March 5, 2010 Jeese, just asking. Ok, keep hacking away at that then. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 5, 2010 Report Share Posted March 5, 2010 If you aren't worried about the footer anymore, try something like this: replace the two die (" Use browser back button !"); with two die (" Use browser back button !"); (or however many closing divs is appropriate.) I haven't tested this obviously, but try this and let me know if that fixes things for you. The die() function prints out whatever is in the parenthesis, and then the script is completely terminated -- no more code, php or otherwise, will execute/display after the die() statement. Quote Link to comment Share on other sites More sharing options...
virtual Posted March 5, 2010 Author Report Share Posted March 5, 2010 Hey Eric, don't get your knickers in a twist. :/ If you read my posts you would understand that I don't know what the heck I'm doing when it comes to PHP, so I can't even begin to hack away at the premade script because I barely understand it. I drop it in and hope for the best. As I said previously feel free to change or correct whatever, but please explain it like you were talking to a 2 year old.... well maybe a little older than that! Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 5, 2010 Report Share Posted March 5, 2010 Just bumping this topic quickly -- Lynne, I know you posted just after I did and you may have not seen my last post. Quote Link to comment Share on other sites More sharing options...
virtual Posted March 6, 2010 Author Report Share Posted March 6, 2010 (edited) Thanks Ben, I did see the post but I am 8 hours ahead of you so it was too late for me to try it out. replace the two die (" Use browser back button !"); with two die (" Use browser back button ! "); Tried that and it doesn't close out the two divs. I also tried this and it didn't work either - this is why I hate PHP, I just don't get it... echo " Please hit the Back button Please Enter a valid e-mail address\n";$badinput = " Your email was NOT sent Use browser back button\n";$closedivs = " Edited March 6, 2010 by virtual Quote Link to comment Share on other sites More sharing options...
grucker Posted March 6, 2010 Report Share Posted March 6, 2010 Hope this helps. I tried the idea suggested by Falcencreative and it works perfectly. All " in the code should be replaced with ' and includes dont seem to work so you will have to write the full code. the following code was entered in every die which is a pain on a large verified form but it does work. You didnt include you footer code so I cant advise further, maybe if you publish it falcencreative will post the correct code. { die(" You haven't Entered Your First Name. Go back and Enter your First Name ". mysql_error());} Quote Link to comment Share on other sites More sharing options...
falkencreative Posted March 6, 2010 Report Share Posted March 6, 2010 What I posted should work fine... And your method should have also worked. I'm guessing there may be something else going on here that's affecting things. Can you post your entire code -- both the page that displays the contact form, and also the entire page that processes the form -- either here or send it to me via IM or my email (ben [at] falkencreative.com). That way I can test it on my local machine. Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.