...

View Full Version : Webite Form - Send current page URL



ratzz
10-24-2012, 09:50 PM
Hi All,

I'm pretty new to Javascript, and I'm also not sure if this problem would be best suited to PHP ...

I am a photographer and provide clients with preview and 'BuyNow' options on my website.

The way this is being done at the moment is that each image has an 'image number' and its the customers responsibility to provide this correctly at the PayPal checkout.

What I would like to do is to pass the current pages URL into the checkout via a variable option in PayPal.

Each image has its own unique page, and therefore I can identify the image they want from this.

E.g. http://www.mywebsite.co.uk/phtoshootname/IMG_1234.html

Giving 'IMG_1234' and the image they want to buy.

I have spent a few weeks crawling through the internet and found the following option:

<input type="hidden" name="item_name" value="<?php echo basename($_SERVER['SCRIPT_FILENAME'],".php");?>" readonly />

I'm not even sure if the syntax is correct in the code, and all that gets passed through to the checkout is the actual code, and not the URL.

Can any of you guys help?

Many thanks
Simon

VIPStephan
10-24-2012, 10:16 PM
This has nothing to do with JS, moved to PHP forum.

ratzz
10-25-2012, 02:01 PM
Thanks for that Stephan,

As I said, I'm not sure if its a PHP or Java thing! I have seen attempts using both but as yet I've not been successful..!

ratzz
10-25-2012, 02:05 PM
I've just seen if this code would work with what I'm trying to do:


<?php
$url = isset ($_GET['url']) ? $_GET['url'] : ""; // Retrieves $_GET variable from URL named 'url'

?>


<input type="hidden" name="item_name" value="<?php echo $url; ?>" />

But that just sends the value "<?php echo $url; ?>" !!!

I'm totally lost on this!

abduraooft
10-25-2012, 02:23 PM
value="<?php echo basename($_SERVER['REQUEST_URI'],".php");?>" ?

ratzz
10-25-2012, 10:13 PM
Thanks for that ...

I gave it a try, but on the web page I was getting " /> which is the closing command ...

I've attached an image of what I get in the cart as opposed to the actual URL. It just posts the code!

ratzz
10-27-2012, 02:20 PM
Just to add, I've tried the code without the " and also tried '

I'm guessing this is beyond what is possible with PHP...?

abduraooft
10-27-2012, 03:01 PM
Are you sure that you've tried it like
<input type="hidden" name="item_name" value="<?php echo basename($_SERVER['REQUEST_URI'],".php");?>" /> ?

ratzz
10-28-2012, 10:23 PM
Ok... Tried that code, exactly, but still no joy.

Part of the line's code shows in the webpage also (as text) as mentioned before ...

" /> shows which is the closing three / four characters of the line ...

Uploaded anyway, and still just passes the text enclosed in "<?php echo basename($_SERVER['REQUEST_URI'],".php");?>" to the PayPal site and NOT the URL.

This is driving me nuts ...

ratzz
10-28-2012, 11:06 PM
Could this be better done in Javascript?

ratzz
11-12-2012, 04:44 PM
Well, I'm guessing this can't be done.

Thanks for trying all ... I will find another solution as PHP isn't up to the job here...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum