Page 1 of 1
Series of questions
Posted: Thu Oct 13, 2005 3:03 am
by Daz Wilde
I want to do a site where i can ask a series of questions for booking an advert
So for example:
Pick Advert Type: small - medium - large
back next
(then it moves on to the next page)
Type Description: [textfield]
back next
(then it moves on to the next page)
Enter you details: [textfield] - [textfield] - [textfield]
Submit
Then all the information is sent through via email just like a normal contact form.
Just like placing an ad on autotrader..... would this be easy to do???
Cheers
Posted: Thu Oct 13, 2005 4:57 am
by AndrewBacca
Why don't you just create a form and send it to another page that will send the emai?
Posted: Thu Oct 13, 2005 9:56 am
by pickle
Ya, you could make a single page with all of this stuff in one form, that it then emails. Or, you could make the page only show one question at a time, but keep posting the previous data so that at the end, it has all the data. Or, you could make the page store each question in a cookie/session, which is then read at the end and emailed.
Long story short - it's certainly doable.
Posted: Thu Oct 13, 2005 11:49 am
by Daz Wilde
pickle wrote:Ya, you could make a single page with all of this stuff in one form, that it then emails. Or, you could make the page only show one question at a time, but keep posting the previous data so that at the end, it has all the data. Or, you could make the page store each question in a cookie/session, which is then read at the end and emailed.
Long story short - it's certainly doable.
I'd prefer to do it on a page by page question by question as i dont want to bombard them with all the questions on one page.
How do you recommend doing it then?
Posted: Thu Oct 13, 2005 12:34 pm
by pickle
Well, you can either use forms, sessions or cookies
Using forms, you'd have to gather all the relevant POST data, and put them in as hidden form elements on the current page. For example, if the first question asks them for their name, then when the second question is loaded, you'd have to pull the first name field from $_POST, and store it as a hidden field in the form that asks the second question. Then, when the second question is submitted, the data from the first question is submitted too.
Using sessions, you'd have to call session_start() beginning of the page, then store any POST data in a session variable. Then when you're ready to email, just use the session data. This is probably the way I'd do it.
Using cookies, you'd have to store each question in either it's own cookie, or concatenate all the questions into a string and store it in a cookie. This would break if the user had cookies turned off though.
Using sessions is probably the way to go.
Posted: Thu Oct 13, 2005 5:32 pm
by Daz Wilde
pickle wrote:Well, you can either use forms, sessions or cookies
Using forms, you'd have to gather all the relevant POST data, and put them in as hidden form elements on the current page. For example, if the first question asks them for their name, then when the second question is loaded, you'd have to pull the first name field from $_POST, and store it as a hidden field in the form that asks the second question. Then, when the second question is submitted, the data from the first question is submitted too.
Using sessions, you'd have to call session_start() beginning of the page, then store any POST data in a session variable. Then when you're ready to email, just use the session data. This is probably the way I'd do it.
Using cookies, you'd have to store each question in either it's own cookie, or concatenate all the questions into a string and store it in a cookie. This would break if the user had cookies turned off though.
Using sessions is probably the way to go.
Looks like sessions is the best way your right.
As i am just a newbie though it seems pretty difficult - i'm just used to single page forms, do you have a template i could work off or know of one mate?
Thanks again!!
Posted: Thu Oct 13, 2005 5:57 pm
by pickle
No template, but here's some pseudo-code:
Code: Select all
<?PHP
session_start();
$_SESSION['question1'] = $_POST['question1'];
?>
<form name = 'question2form...>
<input type = "text" name = "question2">
<input type = 'submit'>
</form>
This kind of thing should be done on every page, for every question. On the last page, just loop through every $_SESSION variable you've set, and throw it into your email.
Posted: Sat Oct 15, 2005 3:33 am
by Daz Wilde
pickle wrote:No template, but here's some pseudo-code:
Code: Select all
<?PHP
session_start();
$_SESSION['question1'] = $_POST['question1'];
?>
<form name = 'question2form...>
<input type = "text" name = "question2">
<input type = 'submit'>
</form>
This kind of thing should be done on every page, for every question. On the last page, just loop through every $_SESSION variable you've set, and throw it into your email.
Cheers mate but its baffled me now, not sure ill be able to suss this out.
Posted: Sun Oct 16, 2005 6:29 am
by s.dot
It's not really that difficult.. just think of it in english.
Whenever someone answers one of your form questions, and then submits that answer, it will be stored in a variable. $_POST['thequestionanswered'] is this variable.
Then you're using a big container ( we'll call it $_SESSION

) to store this variable in.
Each time a question gets answered, you store it's variable in the container. Then when you're ready to submit all of the information, after all of the questions get answered.. grab your data from your container! Just like it was submitted all at once.
Posted: Sun Oct 16, 2005 10:54 am
by Daz Wilde
scrotaye wrote:It's not really that difficult.. just think of it in english.
Whenever someone answers one of your form questions, and then submits that answer, it will be stored in a variable. $_POST['thequestionanswered'] is this variable.
Then you're using a big container ( we'll call it $_SESSION

) to store this variable in.
Each time a question gets answered, you store it's variable in the container. Then when you're ready to submit all of the information, after all of the questions get answered.. grab your data from your container! Just like it was submitted all at once.
Mmmmm you make it sound so simple....
I'll have a try but its bound to go wrong somewhere?
It should only be about 3 pages with different questions on.
If im struggling you'll have to help.