Jump to content


Photo

help im stuck on passing vars from form to php and back


  • Please log in to reply
3 replies to this topic

#1 pstanbra

pstanbra
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 20 October 2006 - 06:27 PM

Hey - If sum1 cud help me u will ease my headache.
I have a html  posting to php outlined below. However based on form input, php will redirect to a paymeent page. However I want to take all the variables from the previous form onto the payment gateway form...




here is my php file:

$Message = "";
    if (!is_array($HTTP_POST_VARS))
    return;
reset($HTTP_POST_VARS);
while(list($key, $val) = each($HTTP_POST_VARS)) {
$GLOBALS[$key] = $val;
if (is_array($val)) {
$Message .= "<b>$key:</b> ";
foreach ($val as $vala) {
$vala =stripslashes($vala);
$Message .= "$vala, ";
}
$Message .= "<br>";
}
else {
$val = stripslashes($val);
if (($key == "Submit") || ($key == "submit")) { }
else { if ($val == "") { $Message .= "$key: - <br>"; }
else { $Message .= "<b>$key:</b> $val<br>"; }
}
}
} // end while
$Message = "<font face=verdana size=2>".$Message;
mail( $MailToAddress, $MailSubject, $Message, "Content-Type: text/html; charset=ISO-8859-1\r\nFrom: ".$email."\r\nBCc: ".$MailToCC);


if(isset($_POST['service'])){
     switch($_POST['service']){
          default:
               header("Location:http://www.google.co.uk");
               break;
          case 'PC Health Check':
               header("Location:http://www.sysfix.co.uk/pay.html");
               break;
          case 'Technical Support':
               header("Location:http://www.yahoo.co.uk");
               break;
     }
}
?>

so i basically get emaild a form to email - then a redirect to a payment url -
FYI - the form tags relate to the tags expected by the form on the gayeway page.

I hope u understand what im trying to address...







#2 pstanbra

pstanbra
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 21 October 2006 - 09:13 AM

eg - i need this header("Location:http://www.sysfix.co.uk/pay.html");
to be like

header("Location:http://www.sysfix.co.uk/pay.html" ?var1&var2"

#3 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 21 October 2006 - 09:53 AM


<?php

header("Location: http://www.sysfix.co.uk/pay.php?var=$var&var2=$var2"); 
exit();

?>



#4 pstanbra

pstanbra
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 22 October 2006 - 08:25 PM

hi - I didnt realise it was that easy.. Well, it's kinda what i'm looking for;

so my form sends the variable to a php file which is a form to email script. I then set a redirect based on a form dropdown and have changed the link so it passes the variables on like you said as below ..

header("Location:http://www.sysfix.co.uk/pay.html?firstname=$firstname"

However the redirect to pay.html also has a form. I've set up all form elements with the same variable names and have marked the elements as hidden so all that remains is a pay now button. How do these variables get passed on??

I tried changing my form element to
<input name="firstname" type="hidden" id=$firstname> however all i get in the payment field on my card processor is $firstname  arghhh

any ideas?
 




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users