NickG21 Posted January 11, 2007 Share Posted January 11, 2007 i was wondering if anyone had a good way to make a page display one page at a time. I have been trying by passing a hidden variable but i am unable to do error handling on each individual page. [code]<?phpsession_start(); <--- at top of page IF (!isset($_POST['step'])) { include "ListInfo.php";} <----first form page ELSEIF ($_POST['step'] == 2){ include "OptServices.php";} <------ second form page ELSEIF ($_POST['step'] == 3){ include "ContInfo.php";}<------third form page ELSEIF ($_POST['step'] == 4){ include "BillInfo.php";}<----fourth form page ELSEIF ($_POST['step'] == 5){ include "Survey.php";}<----fifth form page ELSEIF ($_POST['step'] == 6){ include "Terms.php";} <--- sixth form page?>[/code]and in each page i include validation code with this as a way to switch to the other form, this is the part i can't get right[code]session_start();foreach($_POST as $key => $var) { $_SESSION[$key] = $var; }if (isset($_POST['ListInfo'])){$errorList = array();}if(empty($NameForList)){ $error[] = "List Name";} <-----more validation code------>if(count($errorList) > 0){ $errors = "<p class=\"error\"><big><b>The Following Errors Were Found, Please Re-Enter:</b></big><br/>". implode('<br />', $errorList). "</p>"; }ELSE{ echo "<input type='hidden' value='2' name='step'>"; include_once('headerImage.php');}[/code] the pages initially display with all of the errors showing and when passed to the next form the previous one comes up underneath full of the input......any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/33792-including-multiple-pages/ Share on other sites More sharing options...
Daniel0 Posted January 11, 2007 Share Posted January 11, 2007 First of all I'd use a switch: [code]<?phpsession_start(); // just because you had it, no need for this code if it's the onlyswitch($_POST['step']){ case '1': include 'ListInfo.php'; break; case '2': include 'OptServices.php'; break; // etc... default: // sort of like the "else" in this. it is if the other values won't "work" include 'home.php'; break;}?>[/code]For the other file (read comments!): [code]<?phpsession_start();foreach($_POST as $key => $var){ $_SESSION[$key] = $var;}if(isset($_POST['ListInfo'])){ $errorList = array();}if(empty($NameForList)) // where does this come from??{ $error[] = "List Name"; // is it supposed to add to $errorList instead of $error?}// more validationif(count($errorList) > 0){ $errors = "<p class=\"error\"><big><b>The Following Errors Were Found, Please Re-Enter:</b></big><br/>". implode('<br />', $errorList). "</p>";}else { echo "<input type='hidden' value='2' name='step'>"; include_once('headerImage.php');}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33792-including-multiple-pages/#findComment-158487 Share on other sites More sharing options...
NickG21 Posted January 11, 2007 Author Share Posted January 11, 2007 in order to use a switch wouldn't i have to post to headerImage.php where the include statement is? i was trying to keep the validation in the form page (ListInfo.php etc...) and the error messages still echo when the page is initially loaded and when the first page is submitted with correct information the second form is loaded and the first one is included underneath still.Any help would be great Quote Link to comment https://forums.phpfreaks.com/topic/33792-including-multiple-pages/#findComment-158525 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.