Jump to content

$_GET variables in include


scarhand

Recommended Posts

I have this code:

 

<?php

$item_name = urlencode('product name');
$payment_amount = urlencode('20.00');
$payer_email = urlencode('[email protected]');

$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
https://forums.phpfreaks.com/topic/221229-_get-variables-in-include/
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" => "[email protected]"
);
include "ipn.php";

?>

if you run this:

 

<?php

$item_name = urlencode('product name');
$payment_amount = urlencode('20.00');
$payer_email = urlencode('[email protected]');

$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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.