PHP: passing data on to multiple pages

BulletHole24

Weaksauce
Joined
Apr 22, 2005
Messages
109
OK, I already know how to pass data from a form (user input) to another page. The problem I'm facing right now with what I'm doing is the fact that I don't know how to pass different variables on to different pages. The form I have made consists of a name field, a price field, a description field, and 10 fields for uploading pictures. So far what it does is it takes what the user input into the name field and creates a directory for that name. So if the user inputs "Bob," it creates a directory called "Bob" and then it takes the uploaded pictures and moves them to that directory. Now what I need it to do is somehow take what the user has input into the price and description fields and echo them on a completely different page (along with the name and pictures of course). Is there anyway this can be done?
 
Probably the easiest method is to put them in $_SESSION (you'll have to be sure to set up sessions on the appropriate pages) and access it from there on the next page.

You can, however, just redirect processingpage1.php to processingpage2.php?foo=this&bar=that and pass them that way.
 
you know... that would make sense considering i'm going to put these pages into a session anyway. lol, thanks.
 
hmm... just figured another way i could do it was in a form. pass the "price" and "description" on via form in a hidden input field and have the user hit "Continue" like you see with a lot of forms these days when you're signing up for something.
 
yeah, absolutely. I didn't realize that you meant that the intermediate page would be shown to the user.

Just remember that with this solution, you'll want to vet the passed info between each reception and use, not just after initial reception. A malicious user could easily insert their own values into a form that submits to one of your pages.
 
hmm... now i've run into a new problem. now what my script does is the user inputs "name," "price," "description," and then the images. after the user hits "submit," it creates a page called "name.php" (name being the name that the user put. so say i input bob, it would make bob.php). then it takes a file i made called "outline.php" which is the layout of the page of an item and turns that whole file into a string. then it writes that string into the newly created bob.php. outline.php looks like this:

Code:
<?php
	include("header.php");
        $name = $_POST['passname'];
	$pic1 = "images/$name/$name" . "1.jpg";
	$pic2 = "images/$name/$name" . "2.jpg";
	$pic3 = "images/$name/$name" . "3.jpg";
	$pic4 = "images/$name/$name" . "4.jpg";
?>

<table width=600 border=0 valign=top>
<tr>
<td colspan=2><h1><b><?php echo($name); ?></b></h1></td>
</tr>
<tr>
<td colspan=2><h2><b><?php echo($_POST['passprice']); ?></b></h2></td>
</tr>
<tr class="twelve">
<td colspan=2 align=left><?php echo($_POST['passdesc']); ?></td>
</tr>
<tr>
<td align=center><img src="<?php echo($pic1); ?>" border=0></td>
<td align=center><img src="<?php echo($pic2); ?>" border=0></td>
</tr>
<tr>
<td align=center><img src="<?php echo($pic3); ?>" border=0></td>
<td align=center><img src="<?php echo($pic4); ?>" border=0></td>
</tr>
<tr class="twelve">
<td colspan=2 align=center>
PayPal button would be here.</td>
</tr>

<?php include("footer.php"); ?>

I know it's a little messy, but anyway... All the "pass" variables are variables from the previous page that needed to be passed on via form in hidden input fields. Then it echoes those variables into the table where you see the echo commands. The problem with this as you may already realize is that it works when the user first sees the page, but if the user were to close their browser and revisit "bob.php," all those echoed strings will disappear because the info that was POSTed earlier is no longer available. Is there anyway way I can make the echoed information permanent on the page?
 
BulletHole24 said:
Is there anyway way I can make the echoed information permanent on the page?
Put it in permanent storage, e.g. some form of database. This could be SQL, a text file, whatever.

You could cookie it, but that's only semi-permanent, and again, raises the opportunity for a malicious user to alter the data.
 
lomn75 said:
Put it in permanent storage, e.g. some form of database. This could be SQL, a text file, whatever.

You could cookie it, but that's only semi-permanent, and again, raises the opportunity for a malicious user to alter the data.


BulletHole24 said:
well someone pointed out to me that it looks like this is the time when i start incorperating MySQL with my code to save the data the user enters and then spit back out... that would be all ready if it weren't for my other problem:

http://hardforum.com/showthread.php?t=931026

:) ^^^
 
Back
Top