Page 1 of 1

header("Location: ... does not work correctly

Posted: Sat Sep 09, 2006 2:57 pm
by vincent
iii

Posted: Sat Sep 09, 2006 3:37 pm
by nickvd
first, i'd recommend buying a php book :)

second, try echoing out what's inside the header() function call, that way you can see what url is being used as the Location.

third, read the integration documentation at paypal, because the way you're doing it (probably) wont work no matter what you do.

Re: header("Location: ... does not work correctly

Posted: Sat Sep 09, 2006 5:56 pm
by Christopher
vincent wrote:What am I doing wrong?
I'd say using a redirect when you should probably be using cURL or a library like Snoopy to submit the data.

Posted: Sat Sep 09, 2006 6:03 pm
by RobertGonzalez
Not to mention your use of $_REQUEST instead of $_GET or $_POST coupled with malformed array index names like '$Telephoneb'. Remember that a single quote is a string literal, so the array index in this example:

Code: Select all

$_REQUEST['$Telephoneb']
would actually be $Telephoneb, not what the value of the variable $Telephoneb is expected to be. To use variables properly in your array index assignments, either remove the quotes altogether (recommended) or wrap them in double quotes (acceptable but not recommended).

Code: Select all

$_REQUEST[$Telephoneb]
// or
$_REQUEST["$Telephoneb"]

It's ok...

Posted: Sat Sep 09, 2006 6:31 pm
by gkwhitworth
In his defense about the quotes...he probably picked it up from a tut or something...I have been doing that until you just mentioned that they don't have to be there. Thanks for that.

--
Greg

Posted: Sat Sep 09, 2006 10:36 pm
by RobertGonzalez
A lot of us have. Then we learn better (usually from here) and the next thing you know we are passing that on to other developers.

Posted: Sun Sep 10, 2006 3:18 am
by vincent
iii

Posted: Sun Sep 10, 2006 3:31 am
by n00b Saibot
i have a hunch you are mistaking field names with variables.. try this instead to see if I am right...

Code: Select all

<?php 
header("Location: https://www.paypal.com/cgibin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&upload=1&currency_code=EUR&business=" . $_POST['salesEmail'] . "&item_name=Order&lc=US&country=US&first_name=" . $_POST['First_Nameb'] . "&last_name=" . $_POST['Last_Nameb'] . "&address1=" . $_POST['Billing_Address1'] . "&address2=" . $_POST['Billing_Address2'] . "&zip=" . $_POST['ZIP_Postal_Codeb'] . "&city=" . $_POST['Cityb'] . "&email=" . $_POST['E_mailb'] . "&H_PhoneNumber=" . $_POST['Telephoneb'] . "&login_email=" . $_POST['E_mailb'] . "&amount=" . $_POST['total'] . "&item_number=" . $_POST['order_id'] . ""); 
?>

Posted: Sun Sep 10, 2006 3:45 am
by vincent
!!!

Posted: Sun Sep 10, 2006 4:50 am
by n00b Saibot
I wrote:i have a hunch you are mistaking field names with variables.. try this instead to see if I am right...
try running it once.. then we will know for sure :)

Posted: Sun Sep 10, 2006 6:00 am
by pedrotuga
a bit of indentation wouldnt make you any bad.

note: i dont recomend you to buy any book... php.net is the best one you can ever have.