Hi. I hope someone can help.
This is propably a no brainer.................
I am trying to create a multipage form......ie............first page has first 6 questions and click to continue. Second page has more questions, and so on until you reach page five which shows summary of answers then allows a submit button to post all answers to database.
The database parts I have no problem with, but the passing between pages is giving me grief.
For one has the first 6 form items in them, I post these using the standard post method to a new php, which then retrieves these variables. Within the form on the second page I add hidden form fields representing the asnwers for page 1 and set the values as the retrieved variables.
The problem I am having is that when I get to the final page, I am again retrieving the variables, but for some reason when I try and echo the values, if a vairable contains more than one word, I still only get the first word in the string.
Why is this?
How can I stop this?
Thanks in advance.
Cosarin
Passing a string from one page to another.
Moderator: General Moderators
Thanks for the reply.
The following is what I am doing between pages in the simplified manner.
Page 1
Then Posted using From method POST to page 2
Page 2
And then inserting this value into a new hidden form field also called message,
I am then once again posting this to page 3 in the same manner with POST
And So on and So until I reach page 5 when instead of placing the value into a hidden field I echo the value
Obviously all code is within php tags in all pages.
But if I enter the string "Hello My Name Is Colin" into the textbox on page one. After I echo it on Page 5 all I get is "Hello"
I hope this helps you help me.
And thanks again
Cosarin
The following is what I am doing between pages in the simplified manner.
Page 1
Code: Select all
<textarea name=message cols=100 rows=8 id=message>Page 2
Code: Select all
@$message = ($_POST['message']);Code: Select all
<input name=message type=hidden id=message value=$message>And So on and So until I reach page 5 when instead of placing the value into a hidden field I echo the value
Code: Select all
echo "$message";But if I enter the string "Hello My Name Is Colin" into the textbox on page one. After I echo it on Page 5 all I get is "Hello"
I hope this helps you help me.
And thanks again
Cosarin
Hmm, I'm confused. If you're using the same hidden field names and the variable $message in PHP to grab the values, aren't you overwriting the values after each submit?
Is it possible maybe to build a 'temp' table in your DB that can hold those temporary values for each session? So as each 'next' button is clicked, you grab all form values, put them as an insert into the temp table, and at the end of the application query the entire temp table - do the math - print the results - and kill the values in the table?
edit: Actually, after reading feyd's post, maybe I'd go with sessions also. Get all the values somewhere as a global storage for your application, and run through those values on the last page of the app. I don't know... Hidden fields just don't seem the best way to handle this IMO.
Is it possible maybe to build a 'temp' table in your DB that can hold those temporary values for each session? So as each 'next' button is clicked, you grab all form values, put them as an insert into the temp table, and at the end of the application query the entire temp table - do the math - print the results - and kill the values in the table?
edit: Actually, after reading feyd's post, maybe I'd go with sessions also. Get all the values somewhere as a global storage for your application, and run through those values on the last page of the app. I don't know... Hidden fields just don't seem the best way to handle this IMO.
Thanks both.
I am very much a newbie to php, and I have thought about the post each page to a temp DB first, and then finalise all the data at the end, but as feyd has mentioned sessions seems obvious now I think of it. I have used sessions before when creating a form verification script, so I shall give that a try.
However thanks jonra for your suggestions.
Cosarin
I shall let you know how I get on!
I am very much a newbie to php, and I have thought about the post each page to a temp DB first, and then finalise all the data at the end, but as feyd has mentioned sessions seems obvious now I think of it. I have used sessions before when creating a form verification script, so I shall give that a try.
However thanks jonra for your suggestions.
Cosarin
I shall let you know how I get on!
- xpgeek
- Forum Contributor
- Posts: 146
- Joined: Mon May 22, 2006 1:45 am
- Location: Kyiv, Ukraine
- Contact:
Re: Passing a string from one page to another.
Sorry for Englis. I try.Cosarin wrote:skip
1)Use tables to store tmp data.
2)Use sessions to store tmp data.
3)Use tmp files
3)Don't use hidden fields if you don't want check it all time when user submit form.
I prefer the database variant but sometimes sessions is prefered.