Modify Post Headers

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
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:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
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 :)
 

gomarc

Member
Messages
516
Reaction score
18
Points
18
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:
<?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:
<?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.
 

nirajkum

New Member
Messages
159
Reaction score
0
Points
0
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
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
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:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
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.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
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.
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
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!
 

espfutbol98

New Member
Messages
200
Reaction score
2
Points
0
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.
 
Top