Jump to content

$_GET variables in include


scarhand
 Share

Recommended Posts

I have this code:

 

<?php

$item_name = urlencode('product name');
$payment_amount = urlencode('20.00');
$payer_email = urlencode('me@email.com');

$getvars = "?item_name=$item_name&payment_amount=$payment_amount&payer_email=$payer_email";

include "http://www.mysite.com/ipn.php$getvars";

?>

 

It only seems to be passing $item_name, the other 2 variables come up as being set, but are empty.

Link to comment
Share on other sites

If using http_build_query doesn't fix it, the problem is using the wrong URL variables - either in that code or your ipn.php.

 

In general, don't include your own PHP scripts like that. Don't use http://www.mysite.com. Include the file as it exists on your server - where it is on the hard drive. No URL arguments. Just the filename.

Instead of the URL you can just define $_GET appropriately.

$_GET = array(
    "item_name" => "product name",
    "payment_amount" => "20.00",
    "payer_email" => "me@email.com"
);
include "ipn.php";

?>

Link to comment
Share on other sites

if you run this:

 

<?php

$item_name = urlencode('product name');
$payment_amount = urlencode('20.00');
$payer_email = urlencode('me@email.com');

$getvars = "?item_name=$item_name&payment_amount=$payment_amount&payer_email=$payer_email";

echo $getvars;

?>

 

you get this:

?item_name=product+name&payment_amount=20.00&payer_email=me%40email.com

 

is that the GET data you expect to add to the included page?

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.