[PayPal & PHP] - Übermittlungsprobleme mit $_POST,$_GET u. Co.



  • Hallo

    Kennt sich irgendwer in Paypal aus? Ich habe mir die Klasse PayPAl von phpclasses.org runtergeladen und dementpsrechend angepasst. Die Zahlungen funktionieren alle. Dort hat es einen Bereich "success" wo drin steht, dass man hier beispielsweise Aktionen reinschreiben kann, wenn die Zahlung erfolgreich verlaufen ist.

    Zum Beispiel nach erfolgreicher BEzahlung die Eintragung in eine Datenbank, anhand von der angegeben E-Mail Adresse und Benutzerdaten VOR dem Aufruf des Bezahlungsformulares.

    Allerdings klappt das nicht! Ich habe ein Feld "Email" und möchte dies danach im Script mit $_POST, $_GET, $_REQUEST weiterverwenden. Ich habe alle drei Varianten schon ausprobiert, das Ergebnis ist immer gleich null! Reinschreiben in die DB tut er zwar, jedoch gehen alle Infos wie E-Mail., gewünschter Benutzername usw. verloren. Warum das denn?

    Kennt sich wer aus und weiss wie man das sonst lösen könnte??

    Hier noch der Code (Auschnitt, unter SUCESS dann das, was ich eigentlich möchte):

    <?php
    include("sql_config.inc.php");
    
    	$connectionid = mysql_connect ($db_host, $db_user, $db_pass);
        if (!mysql_select_db ($db_name, $connectionid))
        {
          die ("Keine Verbindung zur Datenbank");
        }
    
        mysql_query("INSERT INTO account (acc_nr, nachname, vorname, email, credits) VALUES ('none', '".$_POST['last_name']."', '".$_POST['first_name']."', '".$_POST['email']."', '0');");
    
    ...
    
    // Setup class
    require_once('paypal.class.php');  // include the class file
    $p = new paypal_class;             // initiate an instance of the class
    $p->paypal_url = 'https://www.paypal.ch/cgi-bin/webscr';   // testing paypal url
    //$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';     // paypal url
    
    // setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php')
    $this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    
    // if there is not action variable, set the default action of 'process'
    if (empty($_GET['action'])) $_GET['action'] = 'process';
    
    switch ($_GET['action']) {
    
       case 'process':      // Process and order...
    
          // There should be no output at this point.  To process the POST data,
          // the submit_paypal_post() function will output all the HTML tags which
          // contains a FORM which is submited instantaneously using the BODY onload
          // attribute.  In other words, don't echo or printf anything when you're
          // going to be calling the submit_paypal_post() function.
    
          // This is where you would have your form validation  and all that jazz.
          // You would take your POST vars and load them into the class like below,
          // only using the POST values instead of constant string expressions.
    
          // For example, after ensureing all the POST variables from your custom
          // order form are valid, you might have:
          //
          // $p->add_field('first_name', $_POST['first_name']);
          // $p->add_field('last_name', $_POST['last_name']);
    
          $p->add_field('business', 'zensierte@ema.il');
          $p->add_field('return', $this_script.'?action=success');
          $p->add_field('cancel_return', $this_script.'?action=cancel');
          $p->add_field('notify_url', $this_script.'?action=ipn');
          $p->add_field('item_name', 'Paypal Test Transaktion');
          $p->add_field('currency_code', 'CHF');
          $p->add_field('amount', '00.10');
    
          $p->submit_paypal_post(); // submit the fields to paypal
          //$p->dump_fields();      // for debugging, output a table of all the fields
          break;
    
       case 'success':      // Order was successful...
    
          // This is where you would probably want to thank the user for their order
          // or what have you.  The order information at this point is in POST
          // variables.  However, you don't want to "process" the order until you
          // get validation from the IPN.  That's where you would have the code to
          // email an admin, update the database with payment status, activate a
          // membership, etc.
           $acc_nr = rand(0,1000);
    	    mysql_query("UPDATE account SET acc_nr= '".$acc_nr."', credits='10' WHERE email = '".$_REQUEST['email'].";");
    
    	  mail($_REQUEST['email'], "Zahlung erhalten und Mitgliedschaft eröffnet", "Vielen Dank für Deine Bezahlung. Die Mitgliedschaft ist eröffnet. Deine Accountnummer lautet: ".$acc_nr." und Du hast nun 10 Credits.", "From:memberservices@globesolutions.ch");
    
          echo "<html><head><title>Success</title></head><body><h3>Thank you for your order.</h3><br /><br />";
          echo "POST mail: ".$_REQUEST['email']."<br />";
          echo "REQUEST mail: ".$_GET['email'];
          echo "</body></html>";
    
          // You could also simply re-direct them to another page, or your own
          // order status page which presents the user with the status of their
          // order based on a database (which can be modified with the IPN code
          // below).
    
          break;
    
       case 'cancel':       // Order was canceled...
    
          // The order was canceled before being completed.
    
          echo "<html><head><title>Canceled</title></head><body><h3>The order was canceled.</h3>";
          echo "</body></html>";
    
          break;
    
    ....
    
    ?>
    

    Grüsse aus der Schweiz - Wolf



  • Dein INSERT muss unter process, und es muss sich auf $_POST beziehen.

    Gruß Jens


Anmelden zum Antworten