toryadams Posted September 3, 2011 Share Posted September 3, 2011 Ok quick run down... I need to pass a variable from one page[form] to another while skipping a page that is in the middle. The middle page is paypal... after they pay, they are being redirected to a thank you for registering with a email also being sent. But I need their email from the first page[form]. so what i need to figure out or help is: 1. First page is a form, they enter name, last name, address, email and so on 2. They are redirected to paypal to pay for a service. 3. Are directed back to my site for a email to be sent to them, but I need their email from the first page. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/ Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 So just an update, I am going to attempt to pass a variable through the url to the paypal screen to the page it is needed on. so the form will become self processing for the most part other than the email being sent out. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1264982 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 passing the variable through paypal... did not work. Just had to try Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265004 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 would a session be my best bet? Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265008 Share on other sites More sharing options...
MasterACE14 Posted September 3, 2011 Share Posted September 3, 2011 you add the 'custom' field to the paypal button/form: <input type='hidden' name='custom' value='yourvar' /> Then using their Instant Payment Notification (IPN) script that can be generated for PHP on their website you can get the variable on the other end. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265011 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 so just cause my mind is drawing a blank at this point been trying different things all day. In the text field for the value I want them to enter their email again or use a php tag there <?php echo $_POST['email']; ?> style? Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265013 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 if anyone has used ipn on paypal help would be great... Here is the code... <?php $connection = mysql_connect('testingblock.db.6607699.hostedresource.com', 'testingblock', 'KN1ght12') or die(mysql_error()); mysql_select_db("testingblock", $connection)or die(mysql_error()); $req = 'cmd=_notify-validate'; // go through each of the POSTed vars and add them to the variable foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; // In a live application send it back to www.paypal.com // but during development you will want to uswe the paypal sandbox // comment out one of the following lines $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30); //$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // or use port 443 for an SSL connection //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { //email $mail_From = "From: [email protected]"; $mail_To = $email; $mail_Subject = "HTTP ERROR"; $mail_Body = $errstr;//error string from fsockopen mail($mail_To, $mail_Subject, $mail_Body, $mail_From); // $fh = fopen("logipn.txt", 'a');//open file and create if does not exist // fwrite($fh, "\r\n/////////////////////////////////////////\r\n HTTP ERROR \r\n");//Just for spacing in log file // // fwrite($fh, $errstr);//write data // fclose($fh);//close file } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $item_colour = $_POST['custom']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; //full amount of payment. payment_gross in US $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; //unique transaction id $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; if (($payment_status == 'Completed') && //payment_status = Completed ($receiver_email == "[email protected]") && ($payment_currency == "GBP") && (!txn_id_used_before($txn_id))) { $receiver = "[email protected]"; $random_num = rand(1,10); if (isset($random_num)){ $query = sprintf("SELECT email FROM access_codes WHERE id='".$random_num."'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); while(!empty($row['email'])){ $random_num = rand(1,10); var_dump($random_num); $query = sprintf("SELECT email FROM access_codes WHERE id='".$random_num."'", mysql_real_escape_string($email)); $result = mysql_query($query); $row = mysql_fetch_assoc($result); } $query2 = sprintf("SELECT codes FROM access_codes WHERE id='".$random_num."'", mysql_real_escape_string($codes)); $result2 = mysql_query($query2); $row2 = mysql_fetch_assoc($result2); echo $row2['codes']; $Name = "The Streetbeat Team"; $email = "[email protected]"; $recipient = "$receiver"; $mail_body = "This is your code for the 10 day free trial of the StreetBeat Int $random_num Please save this email and use the code for your trial."; $subject = "This is your coupon code for your trail on U-Network"; $header = "From: ". $Name . "<" . $email . ">\r\n"; ini_set('sendmail_from', '[email protected]'); mail($recipient, $subject, $mail_body, $header); $sql = "UPDATE `access_codes` SET `email` = '{$_POST['email']}' WHERE id='".$random_num."'"; mysql_query($sql) or die(mysql_error()); echo 'A email has been sent to the email you provided. Which is'.$recipient.'If this is not correct please contact us, by email at [email protected], with your correct email and the email you provided'; } $mail_To = "[email protected]"; $mail_Subject = "completed status received from paypal"; $mail_Body = "completed: $item_number $txn_id"; mail($mail_To, $mail_Subject, $mail_Body); } else { // send an email to say that something went wrong $mail_To = "[email protected]"; $mail_Subject = "PayPal IPN status not completed or security check fail"; // //you can put whatever debug info you want in the email // $mail_Body = "Something wrong. \n\nThe transaction ID number is: $txn_id \n\n Payment status = $payment_status \n\n Payment amount = $payment_amount"; mail($mail_To, $mail_Subject, $mail_Body); } } else if (strcmp ($res, "INVALID") == 0) { // // Paypal didnt like what we sent. If you start getting these after system was working ok in the past, check if Paypal has altered its IPN format // $mail_To = "[email protected]"; $mail_Subject = "PayPal - Invalid IPN "; mail($mail_To, $mail_Subject, $mail_Body); } } //end of while fclose ($fp); } ?> here is the email i am getting We have had an INVALID response. The transaction ID number is: username = and i am using sandbox... so i did something wrong. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265162 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 so now the IPN is working fine, but I am needing to now pass my custom email input through paypal... problem is when using a buy now button it is like clicking a link so my email input the user is using does not pass through Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265181 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 ok so my IPN script works now... I still am not able to recieve the email var i need on my generation page. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265212 Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2011 Share Posted September 3, 2011 And you've opened another thread for that problem, correct? Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265213 Share on other sites More sharing options...
toryadams Posted September 3, 2011 Author Share Posted September 3, 2011 that was by accident. I am sorry about that... I was not paying attention when i hit new topic. Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265214 Share on other sites More sharing options...
Pikachu2000 Posted September 3, 2011 Share Posted September 3, 2011 I'll go ahead and merge them to one thread then to keep the problem all together. EDIT: Merge done . . . Quote Link to comment https://forums.phpfreaks.com/topic/246326-passing-var/#findComment-1265216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.