/    Sign up×
Community /Pin to ProfileBookmark

sending postdata with header() while redirecting

Hi,

I’ve built a form that excepts a variable dollar amount as a value.
I would like to send this value (along with other postdata) to a processing script (shopping cart service). I’ve tried using cURL without success for this project.

Is there a way to use php’s header() function to send the postdata along with a redirect?

Thanks for reading,
-Mike

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@bokehDec 16.2005 — That's not possible, but you could do it with javascript and It would be simple. The other option is do not redirect them and use your server as the man in the middle. Another way would be send them a final page with all their details displayed and then have a button at the bottom that says confirm order. Have all their data in hidden fields so they can't modify anything. Then when they press confirm they will be submitting the form themselves. If you combined this with the Javascript idea, for 90% of people the form would auto submit without them noticing anything and then the other 10% would have to press a button. Sorry but I can't think of anything better right now.
Copy linkTweet thisAlerts:
@Wart_HogauthorDec 16.2005 — Bokeh,

Thanks for the response.

I was trying to avoid using hidden inputs. The service I am using requires that you submit an email address in the post string. So, I was trying to avoid hardcoding the email address in the html. But I guess that there's no way around it. Thanks again for you help ?

-Mike
Copy linkTweet thisAlerts:
@bokehDec 16.2005 — I was trying to avoid hardcoding the email address in the html.[/QUOTE]You are not hard coding anything... That page would be built dynamically!
Copy linkTweet thisAlerts:
@Wart_HogauthorDec 16.2005 — You are not hard coding anything... That page would be built dynamically[/QUOTE]

hmmm....

Lets say I need to pass two vars via post: $amount and $email

to: http://www.shopping_cart_processor.php (not on my server)

Here's what I have so far:

[list=1]
  • [*]User enters a price value ($amount) into html form that is processed on my server.

  • [*]My script processes the value, error checks and stores the value for $email.

  • [*]If all is well I want to send the two vars via POST to: http://www.shopping_cart_processor.php

  • [/list]


    I thought cURL would work well for this, and it does. It gets the values to the shopping cart script. But for some reason, my domain name is in the location bar instead of http://www.shopping_cart_processor.php. This doesn't bother me but when I click on the "checkout" button the script the processes checkout is generating an error. It is most likely detecting that the from was submited from my domain name and not theirs.

    I would definately like to hear more about your javascript solution.

    I can post the code later, I don't have it on hand at the moment.

    Thanks again,

    -Mike
    Copy linkTweet thisAlerts:
    @bokehDec 17.2005 — I just quickly threw this together in 5 minutes to give you an idea and see if this is what you want. Fill in the 3rd party URL in the form and use php to fill in the hidden fields with the data you have collected. It works in Internet Explorer and Firefox.[code=php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Confirm</title>
    </head>

    <body>
    <form id="letsShop" action="http://merchant.com" method="POST">
    <div>
    <!-- Your collected fields here -->
    <input type="hidden" name="field1" value="value1">
    <input type="hidden" name="field2" value="value2">
    <!-- End your collected fields here -->
    <noscript>
    <input type="submit" value="Confirm Order">
    </noscript>
    </div>
    </form>
    <script type="text/javascript">
    document.getElementById('letsShop').submit();
    </script>
    </body>
    </html>[/code]
    Copy linkTweet thisAlerts:
    @Wart_HogauthorDec 17.2005 — Thats neat...

    Thanks for doing the mock up.

    I'll give it a go later tonight when I'm at home.

    -Mike
    ×

    Success!

    Help @Wart_Hog spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...