Jump to content


Photo

Multi Page Form ?


  • Please log in to reply
5 replies to this topic

#1 Accurax

Accurax
  • Members
  • PipPipPip
  • Advanced Member
  • 246 posts

Posted 17 May 2006 - 07:57 AM

Hi guys, I'll get straight to the point;

I currently have a functioning form, laid out in Html, and posted with the $_POST command. It's a very simple form, with some radio buttons, some drop downs & of course text fields, simple, but it works, [a href=\"http://members.lycos.co.uk/cmbtest\" target=\"_blank\"]you can see it here[/a], its a form for gathering information to allow me to write a persons CV.

All i want my form to do is take the information a user enters and send it to my email inbox, thats it.

However I have a problem with userbility, my form (once complete) is going to be extremely long, and, in an effort to avoid scaring people off i've decided the form must be broken down a bit.

So, I need a simple yet effective method of controlling the visible length of my form, my favoured method would be to have the form divided into 4 segments, each on there own page, personal information on the first page, then education, then work experiance, and finally personal acheivments & comments... for example.

I could do this in a somewhat convulated manner at the moment, but it would result in 4 seperate Emails being sent to my inbox for EVERY user... I would then have to match the peices together using the IP Address... this as i'm sure you can appreciate is not ideal.

What is needed is a way of bundleing the information from each page together and sending it as a single seamless email.

Is MySql the answer? ....... I havnt begun teaching myself this yet.. (3months ago i couldnt speak Html lol) ... I could really do with some kicks and prods in the right direction.

I could also do with an estimate of the difficulty of what im trying to do..... how long is it likley to take me to learn enough to do this? ... time is becoming an issue for this little project so all and any help and assistance is greatly recieved.

Thankyou

Accura

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 17 May 2006 - 09:11 AM

hi,
You could make your forms to contain hidden fields to store values passed on from the previous page, then they will be re-posted as you move on but still never visible for the user. Then you will have all form information available at the last stage, ready to email.

You could also look into sessions and see if that could be your solution. You would have to do some checks on existing sessions as you move on from formpage to formpage to verify that information is being passed on.

Mysql is a solution but i dont think it is the best (read: easiest) solution here as you might end up with som partially completed forms if a user decides to quit on e.g. stage 3 - so this would again reguire a clean-up query to remove those.

#3 Accurax

Accurax
  • Members
  • PipPipPip
  • Advanced Member
  • 246 posts

Posted 17 May 2006 - 11:07 AM

hmmm... sounds interesting.

Any chance you could give me a little more advice on the hidden field thing... its not a concept im familiar with im afraid.

thanks [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

#4 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 17 May 2006 - 01:37 PM

its a pure html issue, instead of input type="text" you have input type="hidden"
<? 
// from prev page
$from_page_1 = htmlspesialchars($_POST['from_page_1']);
?>

<form name="page_2" action="page_3.php" method="post" />

<input type="hidden" name="from_page_1" value="<? echo $from_page_1; ?>" />

<input type="text" name="from_page_2" value="" />

<input type="submit" name="page_2_submit" value="next step" />



#5 Accurax

Accurax
  • Members
  • PipPipPip
  • Advanced Member
  • 246 posts

Posted 17 May 2006 - 01:57 PM

Ok, let me see if i have this right, please forgive my ignorance.

The first page of my form will remain unchanged, apart from the submit button will now move the user to stage 2 instead of $_POST -ing the information to my mailbox,

Stage 2 will contain all of the fields the user must fill in.... plus a number of hidden fields that wil store the info from the previous section.

Then assuming (for simplicity) a 2 page form, the submit button on page 2 will $_POST all the information together.

I understand the concept, however i have 1 or 2 questions;

<?
// from prev page
$from_page_1 = htmlspesialchars($_POST['from_page_1']);
?>

<form name="page_2" action="page_3.php" method="post" />

<input type="hidden" name="from_page_1" value="<? echo $from_page_1; ?>" />

<input type="text" name="from_page_2" value="" />

<input type="submit" name="page_2_submit" value="next step" />

In the above code you make referance to $from_page_one ..... do i need to define this as being = to the information in the fields in page one?... and if so... how?

Or, is $from_page_one a generic term that youve used for example... if so... what to replace it with?

Basically i'm just trying to understand how it works.... what the mechanics of it are.

I'm especially confused by;

<?
// from prev page
$from_page_1 = htmlspesialchars($_POST['from_page_1']);
?>

Sorry to be a pain, but i need to understand how things work [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]

#6 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 17 May 2006 - 04:13 PM

$from_page_1 = htmlspesialchars($_POST['from_page_1']);

This is the posted values from a field name called from_page_1 and i gave it the same name in form 2.
$_POST['from_page_1'] contains whatever you wrote in the field named from_page_1, you can ofcourse name it whatever you like and add several fields with different names.
htmlspecialchars() is a php function that makes things more secure in this case, but is not required to use it just to get things working. you can also use strip_tags() etc. instead, strip_tags might be a better solution actually if you are just emailing the results. Look in the [a href=\"http://no.php.net/manual/en/function.strip-tags.php\" target=\"_blank\"]Manual[/a] for further understanding of this.

You are correct in your resume on the form-prosedure.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users