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?
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.
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
Maybe a session can do the job. Something like this:
In the same directory, create end.phpPHP Code:<?php
$a = "This will work!";
session_start();
$_SESSION['value1'] = "Hello!";
$_SESSION['value2'] = $a;
header("Location: end.php");
?>
So when you start the first code, it will redirect you to end.php, including value1 and value2.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 />";
?>
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
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
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.
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 theicon below! (this is even better than "liking" a post)
█ Terms of Service | Acceptable Use Policy | x10Hosting Wiki
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!