crazy8 Posted April 18, 2008 Share Posted April 18, 2008 Ok I have an account creation system that consists of 3 forms. I have done alot of reading on sessions, and as I understand what they do and how they work, I dont understand how to actually implement it into my forms. Now form1.php is all input boxes as is form3.php but form2.php has one section of check boxes. Then I have form4.php which is where all the input that was put into the other forms will be "echoed" for the person to verify all the information. With all that said I guess here is a simple way to ask the question and perhaps get an answer that will help me with all of this. Since there is so much code on the forms thats why I havent posted them. Ok so can anyone give me an example that would work for what I am looking to do? Thanks alot for the help Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/ Share on other sites More sharing options...
crazy8 Posted April 18, 2008 Author Share Posted April 18, 2008 I was hoping I could just edit the last post. Anyway I should mention I do have form3.php working using... <?php session_start(); //below is the session code for step3.php foreach( $_POST as $key => $val ) { $_SESSION['form3'][$key] = $val; } ?> I have this posted on from4.php and this works, so is there a way I could use something like this but for all 3 forms, without any issues? Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-520455 Share on other sites More sharing options...
crazy8 Posted April 18, 2008 Author Share Posted April 18, 2008 Any ideas or suggestions on this one? Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-520800 Share on other sites More sharing options...
947740 Posted April 18, 2008 Share Posted April 18, 2008 It would help to have a little bit more information on the problem. You seem to have an understanding of sessions, because you implemented them just fine in the example you gave. For each page, you just create a session variable for every single value. You can just set a session variable equal to a post variable. <?php \\ Example $_SESSION['varname'] = $_POST['formname'] ?> Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-520827 Share on other sites More sharing options...
discomatt Posted April 19, 2008 Share Posted April 19, 2008 Eh, just give each element a different name across all 3 pages and include this at the top of page 2, 3 and 4 <?php $_SESSION['form_vars'] = $_POST; ?> Then on page4.php <?php function echoFormVar($varname) { if ( isset($_SESSION['form_vars'][$varname]) ) // Prevent XSS injection echo htmlentities($_SESSION['form_vars'][$varname]); } echoFormVar('textbox1'); echo '<br>'; echoFormVar('textbox2'); // ect.. ?> Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-520839 Share on other sites More sharing options...
crazy8 Posted April 19, 2008 Author Share Posted April 19, 2008 Well here is form1.php (actually called step1.php) so here is the code for it, perhaps this will help and thank you both. <?php session_start(); ?> <?php include ('header.inc.php'); ?> <div class = "nround"> <div class = "ntop"><h2>Become a hotspot</h2></div> <div class = "nmiddle" align="left"> <form name="step1" method="post" action="step2.php"> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tbody> <tr> <td colspan="2"><b>Please enter a username and password that you will use to access your account.</b> </td> </tr> <tr> <td class="required">Username</td> <td class="required"><input type="text" name="username" size="20" maxlength="15" value="<?php if( isset($_SESSION['form1']['username']) ) echo $_SESSION['form1']['username']; ?>" /></td> </tr> <tr> <td class="required">Password</td> <td class="required"><input type="password" name="password" size="20" maxlength="15" value="<?php if( isset($_SESSION['form1']['password']) ) echo $_SESSION['form1']['password']; ?>" /></td> </tr> <tr> <td colspan="2"><b>Please enter a valid e-mail address to use in order to activate your account.</b> </td> </tr> <tr> <td class="required">Company Name</td> <td class="required"><input type="text" name="comp_name" size="20" maxlength="15" value="<?php if( isset($_SESSION['form1']['comp_name']) ) echo $_SESSION['form1']['comp_name']; ?>" /></td> </tr> <tr> <td class="required">Establishment Type</td> <td class="required"> <select name="comp_type" value="<?php if( isset($_SESSION['form1']['comp_type']) ) echo $_SESSION['form1']['comp_type']; ?>" /> <option selected>- Select One -</option> <option id="bars" value="Bar">Bar</option> <option id="clubs" value="Club">Club</option> <option id="coffee_shops" value="Coffee Shop">Coffee Shop</option> <option id="resturants" value="Resturant">Resturant</option> </select> </td> </tr> <tr> <td class="required">Address</td> <td class="required"><input type="text" name="comp_address" size="30" maxlength="30" value="<?php if( isset($_SESSION['form1']['comp_address']) ) echo $_SESSION['form1']['comp_address']; ?>" /></td> </tr> <tr> <td class="required">City/Zip</td> <td class="required"><input type="text" name="comp_city" size="10" maxlength="30" value="<?php if( isset($_SESSION['form1']['comp_city']) ) echo $_SESSION['form1']['comp_city']; ?>" /> <input type="text" name="comp_zip" size="5" maxlength="5" value="<?php if( isset($_SESSION['form1']['comp_zip']) ) echo $_SESSION['form1']['comp_zip']; ?>" /></td> </tr> <tr> <td class="required">Phone Number</td> <td>(<input type="text" name="comp_area" size="1" maxlength="3" value="<?php if( isset($_SESSION['form1']['comp_area']) ) echo $_SESSION['form1']['comp_area']; ?>" />) - <input type="text" name="comp_phone" size="8" maxlength="8" value="<?php if( isset($_SESSION['form1']['comp_phone']) ) echo $_SESSION['form1']['comp_phone']; ?>" /></td> </tr> <tr> <td class="required">Email Address</td> <td><input type="text" name="comp_email" size="30" maxlength="20" value="<?php if( isset($_SESSION['form1']['comp_email']) ) echo $_SESSION['form1']['comp_email']; ?>" /></td> </tr> <tr> <td class="required">Website Address</td> <td><input type="text" name="comp_web" size="30" maxlength="20" value="<?php if( isset($_SESSION['form1']['comp_web']) ) echo $_SESSION['form1']['comp_web']; ?>" /></td> </tr> <tr> <td class="required" valign="top">Description</td> <td><textarea name="comp_desc" cols="50" rows="12"> <?php if( isset($_SESSION['form1']['comp_desc']) ) echo $_SESSION['form1']['comp_desc']; ?></textarea></td> </tr> <tr> <td class="verdana11" align="right" width="125"><p></td> <td><a href="step2.php"><img src="img/step2.gif" alt="" border="0"></a></td> </tr> </tbody> </table> </form> </div> <div class = "nbottom"></div> </div> <?php include ('footer.inc.php'); ?> I havent touched this project for sometime so its a little rough and I may change up quite a few things. Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-520895 Share on other sites More sharing options...
crazy8 Posted April 19, 2008 Author Share Posted April 19, 2008 Does that example help? Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-521387 Share on other sites More sharing options...
crazy8 Posted April 21, 2008 Author Share Posted April 21, 2008 Is anyone able to give an assitance with this. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-522579 Share on other sites More sharing options...
redarrow Posted April 21, 2008 Share Posted April 21, 2008 what in header put the session_start() below it then try.......... Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-522581 Share on other sites More sharing options...
crazy8 Posted April 23, 2008 Author Share Posted April 23, 2008 So are you recomending I do this instead? <?php include ('header.inc.php'); ?> <?php session_start(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-525014 Share on other sites More sharing options...
crazy8 Posted April 24, 2008 Author Share Posted April 24, 2008 Am I understanding your recommendation correctly? Quote Link to comment https://forums.phpfreaks.com/topic/101721-session-gloomies/#findComment-526589 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.