+ Reply to Thread
Results 1 to 9 of 9

Thread: Modify Post Headers

  1. #1
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Modify Post Headers

    Can you redirect a user to another page and within the PHP script set some post data? I have googled, but all I found is scripts that use fsockopen() to print the sites contents to the page. Is there a way to do this with a redirect?
    Last edited by Twinkie; 06-24-2009 at 02:01 PM.

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Modify Post Headers

    I think post is a one way street. It's strictly from client->server. Maybe you can use a form with hidden inputs and use a javascript form.submit() to "refresh" the page?

    It may be better to find a different solution because yours sounds like its getting more complicated than it aught to be
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: Modify Post Headers

    Quote Originally Posted by Twinkie View Post
    Can you redirect a user to another page and within the PHP script set some post data? I have googled, but all I found is scripts that use fsockopen() to print the sites contents to the page. Is there a way to do this with a redirect?

    Maybe a session can do the job. Something like this:

    PHP Code:
    <?php

    $a 
    "This will work!";

    session_start();
    $_SESSION['value1'] = "Hello!";
    $_SESSION['value2'] = $a;

    header("Location: end.php");
    ?>
    In the same directory, create end.php

    PHP Code:
    <?php
    session_start
    ();
    $val1 $_SESSION['value1'];
    $val2 $_SESSION['value2'];

    //Close the session
    session_unset();
    session_destroy();

    //Display values
    echo "Value 1 is : $val1 <br />";
    echo 
    "Value 2 is : $val2 <br />"

    ?>
    So when you start the first code, it will redirect you to end.php, including value1 and value2.

  4. #4
    nirajkum is offline x10 Sophmore nirajkum is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    161

    Re: Modify Post Headers

    normally session do all the tricks but not sure what kind of data do you want to carry forward ... .. but mostly session is the best option as we use it for all login script

  5. #5
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: Modify Post Headers

    Well the site the post data is being created for is not mine. I don't want the info printed on the page for security reasons.

    What I am doing is coding a shopping cart to manipulate PayPals Payment Standard Plan for a garage sale site (a bit to small for me to be paying $30 a month for pro). To allow for multiple items to be bought at the same time without me having to keep inventory with PayPal, the shopping cart will generate post data, like a PayPal button, and redirect to PayPal for payments. If possible, I would like the user to see cart.php?do=checkout instead of having a PayPal button printed to the page, especially since the buttons are vulnerable to malicious changes and they cannot be encrypted. Anyone know a work-around for this?
    Last edited by Twinkie; 06-25-2009 at 01:55 AM. Reason: Found the answer to the second question

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Modify Post Headers

    Read the HTTP/1.1 spec section on 3XX responses. Redirects cause the browser to reissue the original request. There's no mechanism for either the server or the browser to alter the request.

    A working alternative that skips the redirect entirely is to generate the values on the last non-PayPal page (possibly using client-side scripting), store them in hidden fields in a form and set the form action to the appropriate PayPal page.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Modify Post Headers

    Quote Originally Posted by Twinkie View Post
    If possible, I would like the user to see cart.php?do=checkout instead of having a PayPal button printed to the page, especially since the buttons are vulnerable to malicious changes and they cannot be encrypted. Anyone know a work-around for this?
    If my memory serves correctly, you can have encryption through paypal for a button...

    Anyways, you could also use the API or use the multiple items option.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  8. #8
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: Modify Post Headers

    Yes you can encrypt a button, or store it on PayPal's server, but that would not allow a user to purchase multiple items at the same time. I was afraid I would have to print a PayPal button to the page, but I guess I have to.

    Thanks misson!

  9. #9
    espfutbol98's Avatar
    espfutbol98 is offline x10 Sophmore espfutbol98 is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Zagreb... želim
    Posts
    200

    Re: Modify Post Headers

    If you had them click a redirect button that sent post data via hidden inputs in a form to another page, it could work. This would be pretty sloppy though. I would just use $_GET and if it's important, base64 encode it or something.

+ Reply to Thread

Similar Threads

  1. Cant Post
    By ShadowmasterX in forum Free Hosting
    Replies: 1
    Last Post: 12-14-2008, 06:56 PM
  2. [GUIDE] Where do I post this?
    By compwhizii in forum Free Hosting
    Replies: 0
    Last Post: 12-06-2008, 08:57 AM
  3. [REQ] 10 credits, to make a post...
    By John Klyne in forum The Marketplace
    Replies: 0
    Last Post: 12-04-2008, 03:15 PM
  4. Gamer's Lounge Rules - Read before you post!
    By tnl2k7 in forum Gamer's Lounge
    Replies: 0
    Last Post: 05-07-2008, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers