Passing data from form

OK, I have a form (SACCC Form) and I am using the PHP file below from the “Register” (submit) button. Now from the mail.php file, I am calling the RegistrationConfirm.html page and want to display the data that was emailed/entered. However, not sure how to do that - pass from form through PHP validation to another page.

Thanks


<?php

$to      	= "myname@oursite.com";
$subject 	= "2011 Car Show Registration";
//$name  = isset($_POST['name'])  ? trim($_POST['name'])  : '';
$name     	= isset($_REQUEST["name"]) ? trim($_REQUEST['name']) : '';
$email    	= trim($_REQUEST["email"]);
$phone    	= trim($_REQUEST["phone"]);
$address1 	= trim($_REQUEST["address1"]);
$address2 	= trim($_REQUEST["address2"]);
$city 		= trim($_REQUEST["city"]);
$state 		= trim($_REQUEST["state"]);
$zipcode 	= trim($_REQUEST["zipcode"]);
$vehyr 		= trim($_REQUEST["VehicleYr"]);
$makemodel 	= trim($_REQUEST["VehicleMkMdl"]);
$waiver 		= trim($_REQUEST["waiverAgree"]);
$pay			= trim($_REQUEST["earlyPay"]);

if($waiver != '1') 
	$waiver = "NO";
else 
	$waiver = "YES";
	

if($pay != '1') 
	$pay = "NO";
else
	$pay = "YES";

$dodgy_strings = array(
                "content-type:"
                ,"mime-version:"
                ,"multipart/mixed"
                ,"bcc:"
);

function is_valid_email($email) {
  return preg_match('#^[a-z0-9.!\\#$%&\\'*+-/=?^_`{|}~]+@([0-9.]+|([^\\s]+\\.+[a-z]{2,6}))$#si', $email);
}

function contains_bad_str($str_to_test) {
  $bad_strings = array(
                "content-type:"
                ,"mime-version:"
                ,"multipart/mixed"
		,"Content-Transfer-Encoding:"
                ,"bcc:"
		,"cc:"
		,"to:"
  );
  
  foreach($bad_strings as $bad_string) {
    if(eregi($bad_string, strtolower($str_to_test))) {
      echo "$bad_string found. Suspected injection attempt - mail not being sent.";
      exit;
    }
  }
}

function contains_newlines($str_to_test) {
   if(preg_match("/(%0A|%0D|\\\
+|\\\\r+)/i", $str_to_test) != 0) {
     echo "newline found in $str_to_test. Suspected injection attempt - mail not being sent.";
     exit;
   }
} 

if($_SERVER['REQUEST_METHOD'] != "POST"){
   echo("Unauthorized attempt to access page.");
   exit;
}

if (!is_valid_email($email)) {
  echo 'Invalid email submitted - mail not being sent.';
  exit;
}

contains_bad_str($email);
contains_bad_str($subject);
contains_bad_str($name);
contains_bad_str($phone);
contains_bad_str($address1);
contains_bad_str($address2);
contains_bad_str($city);
contains_bad_str($state);
contains_bad_str($zipcode);
contains_bad_str($vehyr);
contains_bad_str($makemodel);


contains_newlines($email);
contains_newlines($name);
contains_newlines($phone);
contains_newlines($address1);
contains_newlines($address2);
contains_newlines($city);
contains_newlines($state);
contains_newlines($zipcode);
contains_newlines($vehyr);
contains_newlines($makemodel);

$totalmessage = "
				Name: ........................ $name  \
				Address1: ................... $address1  \
				Address2: ................... $address2)  \
				City: ........................... $city\
				State: ......................... $state  \\r 
				Zip Code: ................... $zipcode  \

				Email: ........................ $email  \\r  
				Phone Number: ......... $phone  \\r 
				Vehicle Year: ............. $vehyr  \\r 
				Vehicle Make, Model:.. $makemodel  \\r 
				I/we have read the waiver and agree to its terms: $waiver  \\r 
				I/we agree to pay the registration fee of 10 dollars upon arrival at the show: $pay  \\r ";
//echo $totalmessage;
//$headers = "From: $email";
//$headers = "From: ";
mail($to, $subject, $headers, $totalmessage);
header("Location: RegistrationConfim.html");
//echo "Thanks for submitting.";
?>

Just in case, here is the RegistrationConfirm.html page code:

<?php 
foreach(array_keys($_POST) as $key){if(!is_array($_POST[$key])){$_POST[$key] = stripslashes(urldecode($_POST[$key]));}else{foreach(array_keys($_POST[$key]) as $key2){$_POST[$key][$key2] = stripslashes(urldecode($_POST[$key][$key2]));}}}
$name = $_POST['name'];
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Thank You</title> 
<link rel="stylesheet" type="text/css" href="/style.css"> 
  <style type="text/css" media="screen">
  	@import "css/main.css";
/*  	@import "css/registration.css";*/
  </style>
</head>

<body>

  <div id="page">
		<div id="header">
			<h1>
				SACCC Registration Thank You!!
			</h1>
         
		</div>
		<div id="content">
      
 		   <p>Hi <?php if(isset($name)){print $name;} ?>. Thank you for registering for our show.</p>

         <p><b>The information you submitted, is shown below:</b></p>
         
         <p> 
         <b>Name:</b> <?php if(isset($_REQUEST['name'])){print $_REQUEST['name'];} else {print 'no name';}?><br> 
         <b>Email address:</b> <?php if(isset($_POST['email'])){print $_POST['email'];} ?><br> 
         <b>Vehicle: </b><?php if(isset($_POST['VehicleYr'])){print $_POST['VehicleYr'.' '.'VehicleMkMdl'];} ?> <br>
         <!-- <b>Comments:</b> <?php if(isset($_POST['comments'])){print $_POST['comments'];} ?> -->
         </p>
         
         <p>Any questions, just let us know.</p>
      
      </div>
      
      <center><a href="index.html" style="text-decoration:none;"><button type="button">Return to Main Page</button></a></center>
 </div>
     



</body> 
</html> 

Thanks
F

the direct way of doing this would be through a session variable

$_SESSION['confirmation']=$totalmessage;

but your commenting out total message in the script. I am not sure why? just un comment the line and the total message will be displayed? maybe I don’t understand the question… :s

smpily,

I commented that out since I want to call the “RegistrationConfirm.html” page. If I uncomment that, what will still not show the data as processed. How can I pass from the original form, process in the PHP routine and then display the entered data from original form in the confirmation page? Don’t understand how to keep passing stuff but if I have to use the session variables… well, how and where would I put the session information you suggested/recommended - in both/either routines?

Thanks
F

Ok, well personally I wouldn’t bother with a conformation page separate from my submission page. But this isn’t about me. :stuck_out_tongue:
but at the top of you email.php page place

session_start();

when validating your data. for example the email var place this after the validation.

$_SESSION['email']=$email;

do that for every $_POST you wish to show on the confirmation page. then in the confirmation page change the

$_REQUEST['WHATEVER'] /* to */ $_SESSION['WHATEVER']