Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,680
    Thanks
    6
    Thanked 1,009 Times in 982 Posts
    This has nothing to do with JS, moved to PHP forum.

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..!

  • #4
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    PHP Code:
    value="<?php echo basename($_SERVER['REQUEST_URI'],".php");?>"
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Attached Thumbnails Webite Form - Send current page URL-error.jpg  

  • #7
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just to add, I've tried the code without the " and also tried '

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

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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");?>" />
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #9
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ...

  • #10
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Could this be better done in Javascript?

  • #11
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •