external links without http?

Discussion in 'Programming' started by olddocks, May 25, 2009.

  1. #1
    i have a form where many people simply forget to put http:// while submitting their site. it doesnt redirect.

    when i create a link it simply points to local file and doesnt work.
    what is the solution to this?
     
    olddocks, May 25, 2009 IP
  2. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #2
    You need to use an if/else statement in PHP or even Javascript.

    heres PHP:
    
    if ((!strstr($url,'http://')) && (!strstr($url,'https://'))){
        $url = 'http://'.$url;
        } else {
        //do nothing?  $url = $url;
        }
    
    PHP:
     
    tguillea, May 25, 2009 IP
    olddocks likes this.
  3. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #3
    thanks :D +rep
     
    olddocks, May 25, 2009 IP
  4. AaliyahRoma

    AaliyahRoma Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <input name="url" value="http://" />
     
    AaliyahRoma, May 26, 2009 IP