Jump to content

Archived

This topic is now archived and is closed to further replies.

Accurax

Multi Page Form ?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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\" /]

Share this post


Link to post
Share on other sites
its a pure html issue, instead of input type="text" you have input type="hidden"
[code]
<?
// 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" />

[/code]

Share this post


Link to post
Share on other sites
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;

[code]<?
// 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" />[/code]

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 [i]how[/i] it works.... what the mechanics of it are.

I'm especially confused by;

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

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\" /]

Share this post


Link to post
Share on other sites
$from_page_1 = htmlspesialchars($_POST['from_page_1']);

This is the posted values from a field name called [i]from_page_1[/i] and i gave it the same name in form 2.
[i]$_POST['from_page_1'][/i] contains whatever you wrote in the field named [i]from_page_1[/i], you can ofcourse name it whatever you like and add several fields with different names.
[i]htmlspecialchars()[/i] 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 [i]strip_tags()[/i] 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.

Share this post


Link to post
Share on other sites

×

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.