Series of questions
Moderator: General Moderators
Series of questions
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
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
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK
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.
Long story short - it's certainly doable.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
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.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.
How do you recommend doing it then?
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.
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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Looks like sessions is the best way your right.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.
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!!
No template, but here's some pseudo-code:
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.
Code: Select all
<?PHP
session_start();
$_SESSION['question1'] = $_POST['question1'];
?>
<form name = 'question2form...>
<input type = "text" name = "question2">
<input type = 'submit'>
</form>Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Cheers mate but its baffled me now, not sure ill be able to suss this out.pickle wrote:No template, but here's some pseudo-code:
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.Code: Select all
<?PHP session_start(); $_SESSION['question1'] = $_POST['question1']; ?> <form name = 'question2form...> <input type = "text" name = "question2"> <input type = 'submit'> </form>
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.
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
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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Mmmmm you make it sound so simple....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.
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.