Jump to content

[SOLVED] 2 page sign up


asmith

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'];?>">

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ! )

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.