Jump to content

passing var


toryadams

Recommended Posts

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.

Link to comment
Share on other sites

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: IPN@tester.com";
$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 == "tory.adams90@yahoo.com") &&  
         ($payment_currency == "GBP") &&  
         (!txn_id_used_before($txn_id))) { 

         $receiver = "tory.adams90@yahoo.com";


$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 = "admin@thestreetbeatint.com";  
    $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', 'admin@thestreetbeatint.com');

    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 admin@thestreetbeatint.com, with your correct email and the email you provided';  

    

}


            $mail_To = "tory.adams90@yahoo.com";
            $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 = "tory.adams90@yahoo.com";
          $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 = "tory.adams90@yahoo.com";
      $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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.