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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Help with a link generator

    Hey guys, I'm looking to create what I'd see as a pretty simple page however I'm still new to PHP and would like to ask for some assistance . Basically I'd like to create a page which allows you to enter a certain number into a input area, allow you to click a submit button and then add that number into an area of a link allowing you to access it faster than it would take you to do so manually.

    For example I enter "150424" in a text box and click submit. It would then give me a link which has been pre-set but allows for the number previously entered to display then becoming "http://www.example.com/150424/etc"

    Any ideas on how I would achieve this? Any help would be much appreciated !

    Cheers
    Last edited by spudmonkee; 10-04-2012 at 08:19 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That would be easy to do:
    PHP Code:
    $sLink sprintf('http://example.com/%d/etc', isset($_POST['yourinputname']) ? (int)$_POST['yourinputname'] : 0); 
    You'll need to do plenty more though. If you don't want to link to be invalid, then you need to take this result and read that location to see if it returns a 200. If it does, then its good.
    If its on your own site, don't apply the http://example.com to it. This is implicit and it will make it easier to determine if a directory or file exists. If you need it to persist, look into using a session to carry the data around.

  • Users who have thanked Fou-Lu for this post:

    spudmonkee (10-04-2012)


  •  

    Posting Permissions

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