Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass $_Post array to another page 1

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

I have a form that accepts user info, evaluates it for errors, and if there are no errors inserts a record into a mysql databse. The page evaluates or targets itself. What I am wondering is... is it possible to pass the contents of the post array, unchanged, to another page after the record insert function based on the value of one of the form fields?

I managed to do it using the url string

i.e:

Code:
if ($_POST['listers'] == 1){
			$insertGoTo = "comp_submissions.php";
			if (isset($_SERVER['QUERY_STRING'])) {
				$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
				$insertGoTo .= $_SERVER['QUERY_STRING'];
			}
			header(sprintf("Location: %s", $insertGoTo));
			// if the record has been inserted, clear the POST array
		    $_POST = array();
	  } else {
	  		$insertGoTo = "colisting.php";
			if (isset($_SERVER['QUERY_STRING'])) {
				$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
				$insertGoTo .= $_SERVER['QUERY_STRING'];
				$insertGoTo .= "user_id=".$_POST['user_id'];
				$insertGoTo .= "&dt_enter=".$_POST['dt_enter'];
				$insertGoTo .= "&dt_service=".$_POST['dt_service'];
				$insertGoTo .= "&service_id=".$_POST['service_id'];
				$insertGoTo .= "&address=".$_POST['address'];
				$insertGoTo .= "&quadrant=".$_POST['quadrant'];
				$insertGoTo .= "&city=".$_POST['city'];
				$insertGoTo .= "&vendor=".$_POST['vendor'];
				$insertGoTo .= "&zone=".$_POST['zone'];
				$insertGoTo .= "&listers=".$_POST['listers'];
				$insertGoTo .= "&signs=".$_POST['signs'];
				$insertGoTo .= "&co_listing=".$_POST['co_listing'];
				$insertGoTo .= "&co_value=".$_POST['co_value'];
				$insertGoTo .= "&status=".$_POST['status'];
				$insertGoTo .= "&instructions=".$_POST['instructions'];
				$insertGoTo .= "&hanger1=".'';
				$insertGoTo .= "&hanger2=".'';
				$insertGoTo .= "&hanger3=".'';
				$insertGoTo .= "&topper=".'';
				$insertGoTo .= "&amount=".$_POST['amount'];
				$insertGoTo .= "&price=".$_POST['price'];					
			}
			header(sprintf("Location: %s", $insertGoTo));
	  }

This code is immediatley after the insert record function.

but there are some values here I don't want the user to be able to see. Can I do something similar to pass the values again as post values, I realise I might be missing something obivous

any help is appreciated

JK
 
I agree with Sleip. look into Session variables, to pass the data.

Imagine if you could just alter the POST array, whats to stop a shady programmer from altering the values like a Total charge on a credit card before it gets to the destination to be processed. It would be a real security hazard.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks sleipnir and vacunita,

I had initially designed the proccess to use session varraibles. But was just trying to look at different approaches. On a side note, does loading up 20 plus session variables affect processing time?

I guess I am just looking for that elusive "fasted possible way".

JK
 
That depends on your server. since the session variables are stored in a file in the server, as long as you have space you can store session variables. I don't think 20 variables will slow down processing noticeably from the User's perspective, Since everything is done server-side.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
On a side note, does loading up 20 plus session variables affect processing time?
Insufficient data for a meaningful answer.

I could, for example store anywhere from 40 bytes to 4,000,000 bytes in 20 session variables. It is not unusual for e-commerse code to store several thousand bytes in session variables.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top