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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vincent
Forum Newbie
Posts: 3
Joined: Sat Sep 09, 2006 2:51 pm

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

Post by vincent »

iii
Last edited by vincent on Sun Sep 10, 2006 12:02 pm, edited 1 time in total.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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.
(#10850)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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"]
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

It's ok...

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
vincent
Forum Newbie
Posts: 3
Joined: Sat Sep 09, 2006 2:51 pm

Post by vincent »

iii
Last edited by vincent on Sun Sep 10, 2006 12:02 pm, edited 3 times in total.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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'] . ""); 
?>
vincent
Forum Newbie
Posts: 3
Joined: Sat Sep 09, 2006 2:51 pm

Post by vincent »

!!!
Last edited by vincent on Sat Nov 25, 2006 9:11 pm, edited 1 time in total.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 :)
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post 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.
Post Reply