Insert http:// in Link Box Automatically??

Discussion in 'PHP' started by DTHBAH2006, Jan 12, 2008.

  1. #1
    I have a text box on my site for users to enter a link of their choice.

    What can I edit to have the http:// show up in the box automatically so they can just type www.theirsite.com instead of entering the http:// everytime?



    Link (optional) :[_________text box___________________]



    Any help with this is appreaciated.

    Thanks,

    :-{
     
    DTHBAH2006, Jan 12, 2008 IP
  2. Kwaku

    Kwaku Well-Known Member

    Messages:
    1,217
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #2
    <intput type="text" name="url" value="http://">

    Is that what you mean?

    Or (better), try something like this after submit:

    $url = $_GET['url'];
    if (strpos($url, "http://")===false) $url = "http://".$url;
     
    Kwaku, Jan 12, 2008 IP
  3. DTHBAH2006

    DTHBAH2006 Active Member

    Messages:
    988
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Worked great!!

    Thanks Kwaku!!

    :D
     
    DTHBAH2006, Jan 12, 2008 IP