nodster Posted June 13, 2007 Share Posted June 13, 2007 Hi guys I've nearly finished a contact form and am now looking to tidy it up a bit. In my code i have a validation 'routine' which saves the errors (depending on whether the input has been completed [think of it as required fields]) and then displays them at the end. This stops the form sending and shows the users where the errors are. here is the code (well part of it) if($name){//----> CHECK input } else{ $error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input } .......... if($toMessage){//----> CHECK input } else{ $error.="You didn't fill out the message box. If you wish to ask a question, please go back and fill out the message box.<br>\n";//----> ERROR if no input } //-------->ERROR FREE?? if($error==""){ echo "Thank you for enquiring about us! A receipt of your submission will be e-mailed to you almost immediately."; //---------------------------------- How can i put the error results (if there are any) into a separate file and redirect the user to it. Basically i want to create a custom error page but show the actual errors that they have made. also how do i incorporate a css layout into a php generated page? Many thanks (edited to add i'm not using a DB to store anything as i don't know SQL that well) Link to comment https://forums.phpfreaks.com/topic/55478-is-this-possible-if-so-how-outout-errors-to-new-page/ Share on other sites More sharing options...
AndyB Posted June 13, 2007 Share Posted June 13, 2007 It's not very user-friendly to show the user their errors on a separate page and expect them to remember the problems when they get back to the previous page. Why not show them the errors on the same page as the form - then they won't need to remember what they did wrong. As to how you incorporate a css layout into a php generated page, that bdepends on what makes up your layout page, but prototypically - <php include("top_of_page_code.php"); // all html/css ABOVE the content // now stick in your php generated content include("bottom_of_page_code.php"); // all html BELOW the content ?> Link to comment https://forums.phpfreaks.com/topic/55478-is-this-possible-if-so-how-outout-errors-to-new-page/#findComment-274178 Share on other sites More sharing options...
nodster Posted June 13, 2007 Author Share Posted June 13, 2007 i tried to do that very thing with JS but couldn't get it to work. Tried using onBlur, onFocusOut to run a function with a popup window but wasn't getting anywhere particularly fast. so with the given code how would i display the error on the same page as as the code works on the submit button the user goes to a generated (white background) page if there are any errors. Link to comment https://forums.phpfreaks.com/topic/55478-is-this-possible-if-so-how-outout-errors-to-new-page/#findComment-274183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.