Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-24-2012, 08:50 PM   PM User | #1
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
Webite Form - Send current page URL

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
ratzz is offline   Reply With Quote
Old 10-24-2012, 09:16 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,614
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
This has nothing to do with JS, moved to PHP forum.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 10-25-2012, 01:01 PM   PM User | #3
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
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 is offline   Reply With Quote
Old 10-25-2012, 01:05 PM   PM User | #4
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
I've just seen if this code would work with what I'm trying to do:

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

?>
Code:
<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!
ratzz is offline   Reply With Quote
Old 10-25-2012, 01:23 PM   PM User | #5
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
PHP Code:
value="<?php echo basename($_SERVER['REQUEST_URI'],".php");?>"
?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 10-25-2012, 09:13 PM   PM User | #6
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
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!
Attached Thumbnails
Click image for larger version

Name:	error.jpg
Views:	16
Size:	17.1 KB
ID:	11651  
ratzz is offline   Reply With Quote
Old 10-27-2012, 01:20 PM   PM User | #7
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
Just to add, I've tried the code without the " and also tried '

I'm guessing this is beyond what is possible with PHP...?
ratzz is offline   Reply With Quote
Old 10-27-2012, 02:01 PM   PM User | #8
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Are you sure that you've tried it like
PHP Code:
<input type="hidden" name="item_name" value="<?php echo basename($_SERVER['REQUEST_URI'],".php");?>" />
?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 10-28-2012, 09:23 PM   PM User | #9
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
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 is offline   Reply With Quote
Old 10-28-2012, 10:06 PM   PM User | #10
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
Could this be better done in Javascript?
ratzz is offline   Reply With Quote
Old 11-12-2012, 03:44 PM   PM User | #11
ratzz
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ratzz is an unknown quantity at this point
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...
ratzz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:43 PM.


Advertisement
Log in to turn off these ads.