Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Senior Member ceetee's Avatar
    Join Date
    Jul 2003
    Posts
    117
    Member #
    2035
    I know how to send GET variables in script using header("location:address?variable=value") but how do you do the equivalent with POST variables?

  2.  

  3. #2
    Junior Member Hobgoblin's Avatar
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    12
    Member #
    3248
    As far as I know, you can't. The whole point of POST is to send information through a form and hide the vars and values from being accessed or changed with the URL.

    Why do you need a header to send a post?
    Michael Willey
    Southland Digital Web Design & Photography
    http://www.sldigi.com/

  4. #3
    Senior Member ceetee's Avatar
    Join Date
    Jul 2003
    Posts
    117
    Member #
    2035
    Sorry I phrased that badly. I want to send POST variables using a script. Not manually with a form. I'm designing a script to insert data from a shopping cart into a database then automatically sending POST variables and user to PayPal.

  5. #4
    Junior Member Hobgoblin's Avatar
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    12
    Member #
    3248
    Ahh.

    As far as I know, it's not possible. If it is, I'd love to know how. PayPal can do POSTs if you use IPN... My IPN script does what you want yours to do, but in reverse order. The user submits to PayPal, then PayPal posts to my IPN script, where I do the needed changes to the database (add permissions, and remove the items from the shopping cart)

    My site's checkout script takes advantage of PayPal's "custom" field.. upon checkout, the product SKUs are placed into a hidden field, separated by colons, and my IPN script uses explode(":", $_POST['custom']) to add the permissions to the DB for the user. This way, they're not given until the purchase is completed... and if they payment is not made, or cancelled, the items are still in the users shopping cart.

    What DB queries are you wishing to execute before the user gets taken to PayPal?
    Michael Willey
    Southland Digital Web Design & Photography
    http://www.sldigi.com/

  6. #5
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Everything is possible. Just gotta find it

    I have a file on my server for you to play with. Post to it, it will tell you what was posted.

    PHP Code:
    <?php

    $host 
    "area51.ny-tech.net"
    $port 80
    $path "/post-test.php";

    //you will need to setup an array of fields to post with 
    //then create the post string 
    $formdata = array (
            
    "data" => "this is first variable named 'data'.",
            
    "data2" => "this is the second variable named 'data2'."
            
    ); 

    //build the post string 
      
    foreach($formdata AS $key => $val){ 
        
    $poststring .= urlencode($key) . "=" urlencode($val) . "&"
      } 

    // strip off trailing ampersand 
    $poststring substr($poststring0, -1); 

    $fp fsockopen($host$port$errno$errstr$timeout 30); 

    if(!
    $fp){ 
     
    //error tell us 
     
    echo "$errstr ($errno)\n"
        
    }else{ 

      
    //send the server request 
      
    fputs($fp"POST $path HTTP/1.1\r\n"); 
      
    fputs($fp"Host: $host\r\n"); 
      
    fputs($fp"Content-type: application/x-www-form-urlencoded\r\n"); 
      
    fputs($fp"Content-length: ".strlen($poststring)."\r\n"); 
      
    fputs($fp"Connection: close\r\n\r\n"); 
      
    fputs($fp$poststring "\r\n\r\n"); 

        
      
    $response "";

      
    //loop through the response from the server 
      
    while(!feof($fp)) { 
        
    $response .= fgets($fp4096); 
      }
      
      echo 
    $response

      
    //close fp - we are done with it 
      
    fclose($fp); 



    ?>
    There and Back Again :Ogre:

  7. #6
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Not sure that was the question.... as I read it what you're actually after is hidden fields... stick them in a form, use php to pre-populate the values and then post it to Paypal.

    Sean

  8. #7
    Senior Member ericbusch's Avatar
    Join Date
    Aug 2003
    Location
    Daejeon, South Korea
    Posts
    241
    Member #
    2779
    I was having the same problem and i got my answer at this thread .

    scroll through the first few posts and you will find i posted a similar question.

    check it out and see if it helps you

    eric
    Blogs For Sale - Each blog is packed with 1000s of signatures and ads are highly integrated into the site. Great CTR! Completely customizable from Admin CP. On Sale!
    Complete Websites For Sale - Fantastic looking sites rich with content. Come complete with domain names. I only have a couple of these.

  9. #8
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Sean,

    he was not asking for hidden fields.

    I want to send POST variables using a script. Not manually with a form.
    There and Back Again :Ogre:

  10. #9
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    You think not?

    If my intention was to post values I would be inclined to populate hidden fields and then submit a form, in the script... not "manually with a form", but still with a form.

    Your script is outputting the results of a posted form... as I read it the requirement was the opposite way around... it needed to pre-populate a Paypal communication which could only use post variables....

    Sean


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:30 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com