asmith Posted November 24, 2007 Share Posted November 24, 2007 a.html : <form action="b.php" method="post" > name : <input type="text name="name" /> <input type="submit" value="next" /> </form> b.php <body> <form action="c.php" method="post"> <p> you sure? </p> <?php echo "name : ".$_POST['name']; echo "<input type=\"hidden\" name=\"name\" value=\"$_POST['name']\" />"; ?> <input type="submit" value="submit" /> </form> </body> c.php mysql .... insert $_POST['name'] .... 2 questions ! 1.isn't this way less secure ? or makes no diffrence than 1 page submitting . or i can have another and safer way making up a "2-page" sign up ? 2.in the b.php how can i add a "back" button ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/ Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 You could store the details from page one in either: a) session variables b) in the db linked to a session id To add a physical back button you could use js, otherwise just print a link/button(sm form) which points back to the previous page with a title of your choice. Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398306 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 lol i'm searching the web i can't find how to set a link for a button ! how can i make a button that i click it opens a link ??? (no javascript) Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398323 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 You've already done it, just don't put any elements in... <form action="lastpage.html" method="post" > <input type="submit" value="Back" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398325 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 To get where the request came from use: $_SERVER['HTTP_REFERER'] Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398327 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 that is submit button, if i want to put a back button beside submit ?? i want to put a back button !! Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398328 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 Thought could use it, look here, http://www.w3schools.com/html/tryit.asp?filename=tryhtml_button and this for more on forms (and other web standards), http://www.w3schools.com/html/html_forms.asp Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398331 Share on other sites More sharing options...
xyn Posted November 24, 2007 Share Posted November 24, 2007 1. Use sessions. Remember they do expire, this can result in problems. A. extend your session expire time. use phpinfo() find the name and use ini_set() to modify it. B. just DONT store the data into a database until the final page, and you have checked the sessions are Active and have data. 2. as explained in B. on your NEXT store all values into the sessions. then if all set and sessions active storoe to database. 3. a back button can be done just by linking directly back to the form, because you can add the value of the field bia the sessions by the following. 4. <input type="text" name="name" value="<?=$_SESSION['name'];?>"> Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398334 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 back button : <form action="previous page.php"> <input type="submit" value="back" /> </form> it works ! but isn't this way of coding a little wierd ? Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398339 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 Why? You wanted a button! Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398341 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 lol good answer, other back button i see on diffrent web pages, are made of this ? (if not made of java or .. ) better to say other php button we see.? Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398344 Share on other sites More sharing options...
xyn Posted November 24, 2007 Share Posted November 24, 2007 I suggest my post would be the best course of action. I use it all the time when i'm developing stuff using forms over several pages. so i can tell you it will work. edit: i forgot to finish my sentance, it will work in a highly advance manor when including other objects, displaying errors etc. Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398345 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 Do you mean a regular link? <a href='".$_SERVER['HTTP_REFERER']."'>BACK</a> You don't really need to use the '$_GET' system... unless your using mod_rewrite... Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398346 Share on other sites More sharing options...
xyn Posted November 24, 2007 Share Posted November 24, 2007 direct link, without using $_SERVER['HTTP_REFERER'] because if your values are stored in sessions, when you go back. as my post stated you can display the users input. Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398347 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 I suggest my post would be the best course of action. I use it all the time when i'm developing stuff using forms over several pages. so i can tell you it will work. edit: i forgot to finish my sentance, it will work in a highly advance manor when including other objects, displaying errors etc. it is now 12:30 am here, i've been at pc about 10 am . so nothing has left from me, could you pleeeaase do me a favor and show me some examples of code of you own, please don't skip somepart , give me all ! i would really apreciate it ! (full code ) (if i figure this out completely then i may rest in peice when i go to bed ! ) Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398348 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 Personally i'd generate it all from same page, just using different 'get' statements to indicate the stage were at and using session variables to store the intermediate data so that it wasn't getting transferred back and forth. If i'm doing something a bit more orwellian then i'd actually put it all to database, linked to session, then i'd be able to look back and rate how competent they are at filling in forms, before properly assigning new data and aptitude summary. Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398349 Share on other sites More sharing options...
xyn Posted November 24, 2007 Share Posted November 24, 2007 Example code: <?php ob_start(); //allow headers to be re-sent. session_start(); if(!$_GET[p]){ $name = (!$_SESSION[fields][0])? $_POST[name]:$_SESSION[fields][0]; $subj= (!$_SESSION[fields][1])? $_POST[subj]:$_SESSION[fields][1]; $mesg = $_POST[mesg]; if(!$_POST[submit]){ ?> <form method=post action=test.php> <input type="text" name="name" value="<?=$name;?>" /> <input type="text" name="subj" value="<?=$subj;?>" /> <textarea name="mesg"><?=$mesg;?></textarea> <input type="submit" name="submit" value="submit!" /> </form> <? }else{ $_SESSION[fields] = array($_POST[name],$_POST[mesg]); header("location: test.php?p=1"); } } else if($_GET[p]==1){ if(!$_POST[submit]){ ?> <form method=post action=test.php> <textarea name="mesg"><?=$mesg;?></textarea> <input type="submit" name="submit" value="submit!" /> </form> <? }else{ if($_SESSION[fields]){ $name = $_SESSION[fields][0]; $subj = $_SESSION[fields][1]; $mesg = $_SESSION[message]; } else{ print "sessions expired."; } } } ob_end_flush(); #flush ?> Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398350 Share on other sites More sharing options...
asmith Posted November 24, 2007 Author Share Posted November 24, 2007 thanks a bunch both you guys ! you really helped ! i may now rest in peace ! Quote Link to comment https://forums.phpfreaks.com/topic/78706-solved-2-page-sign-up/#findComment-398353 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.