Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Help with a link generator
10-04-2012, 05:27 PM #1
- Join Date
- Sep 2012
- Thanked 0 Times in 0 Posts
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 !
Last edited by spudmonkee; 10-04-2012 at 08:19 PM.
10-04-2012, 08:20 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,659 Times in 2,628 Posts
That would be easy to do:
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.PHP Code:
$sLink = sprintf('http://example.com/%d/etc', isset($_POST['yourinputname']) ? (int)$_POST['yourinputname'] : 0);
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: