PDA

View Full Version : How to pass same PHP data to two seperate pages


cottoneye1256
12-06-2008, 03:48 PM
I have a web page that displays correct data from a previously entered info from this page:

<FORM action="score_results_wt.php" method="POST">

info entered here....
<tr>
<td class="lightblue11pt"><b>Guides Name and Address: </b><br>
<input type="text" name="guides_name_address" size="50" maxlength="30">
</td></tr>

<align="left">
<input type="submit" name="scoring1" value="Proceed to Step Two" >
</form>


What I want to do is after data is displayed I want to pass the same form variables to another page so that it displays same info but displayed differently via a button.

thank you

yell0wdart
12-07-2008, 05:10 AM
I have a web page that displays correct data from a previously entered info from this page:

<FORM action="score_results_wt.php" method="POST">

info entered here....
<tr>
<td class="lightblue11pt"><b>Guides Name and Address: </b><br>
<input type="text" name="guides_name_address" size="50" maxlength="30">
</td></tr>

<align="left">
<input type="submit" name="scoring1" value="Proceed to Step Two" >
</form>


What I want to do is after data is displayed I want to pass the same form variables to another page so that it displays same info but displayed differently via a button.

thank you

Well, there are a couple options you've got available to you. Depending on the nature of your website, you could store the data in some sort of persistent environment, like a database (MySQL), or you could use session. Either one would work well enough.

PHP Session:
http://us2.php.net/session

PHP & MySQL:
http://www.php-mysql-tutorial.com/

cottoneye1256
12-08-2008, 12:40 PM
I'm not sure as how to do that also I'm not using any database. The user plugs in some info that they can print in a different display (page) which is where I want the variables to go.

Also what I want to pass on contains about 30 variables. Isn't there some simple way to pass the variables as in the first page where they entered the data then displayed.

thank you

yell0wdart
12-08-2008, 05:22 PM
Well, if it's from one page to another, you could use http POST. If you're writing something more complex, though, you may need to use session to store objects in the server's memory (see first link in my last post).

cottoneye1256
12-08-2008, 05:44 PM
Well, if it's from one page to another, you could use http POST.

I'm already using post.
<FORM action="score_results_wt.php" method="POST">

Everything works fine when the user enters all the data, it displays the results ok also.

What I'm having a problem on is if the user wants to print out (with a different interface) what he entered while still on the 2nd page, I can not get the variables to transfer to the print page (3rd page)

Not sure how to do sessions, will that carry over all the variables?
Do I use one line or have to make a line for each one and where do I put it?

sorry if I ask too much but I taught myself from examples and not sure on this on this one.

yell0wdart
12-09-2008, 03:57 PM
Right, POST only works from one page to another. You'd either have to use Session to store those variables in server memory or rebuild another form to re-POST. Session would be MUCH easier.

Session is really not difficult to use. Just do some googling around for tutorials, like this one:

http://www.tizag.com/phpT/phpsessions.php

Found it by typing "php session tutorial" in the search box on google. Google is a developer's best friend. ;)