making sure a textbox starts with http:// ?

Thread Solved

Join Date: Apr 2009
Posts: 119
Reputation: genieuk is an unknown quantity at this point 
Solved Threads: 0
genieuk genieuk is offline Offline
Junior Poster

making sure a textbox starts with http:// ?

 
0
  #1
May 11th, 2009
Hi,

me again,

I have a textbox that users can enter a url of there website.

I have default value at http:// so when page loads the text box alreay displays http://

I am not sure what i do in PHP to check to make sure that the url starts with http://

can someone tell me what i use in PHP so it checks that the textbox starts with http:// ?

Thank you,
genieuk
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,358
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 164
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: making sure a textbox starts with http:// ?

 
0
  #2
May 11th, 2009
  1. if (!strpos(#_post['textbox'],'http://') == 0) { return false}
/* return false can be any thing, have successfully used header("location: $_server['http_referer]"); to bounce incorrectly filled pages back */ }
or javascript can check similarly in the <form onsubmit='javascript'> before submission
Last edited by almostbob; May 11th, 2009 at 5:09 pm.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: making sure a textbox starts with http:// ?

 
0
  #3
May 12th, 2009
you can check with javascript

apply string function to check if the first 7 characters are "http://"
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: making sure a textbox starts with http:// ?

 
0
  #4
May 12th, 2009
or there is an other option use http:// outside text field and let the users just enter url like www.test.com and you concatenate http:// with url
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 119
Reputation: genieuk is an unknown quantity at this point 
Solved Threads: 0
genieuk genieuk is offline Offline
Junior Poster

Re: making sure a textbox starts with http:// ?

 
0
  #5
May 12th, 2009
Hello Everyone,

Once again thanks for yout help.

I think i will use http:// outside the box and concantanate, i did not think of that.

Thank you to everyone
genieuk
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 10
Reputation: rahul.anand77 is an unknown quantity at this point 
Solved Threads: 0
rahul.anand77 rahul.anand77 is offline Offline
Newbie Poster

Re: making sure a textbox starts with http:// ?

 
-1
  #6
Jun 3rd, 2009
Hi! Just use the preg_match() to check whether the http:// is there or not and take the desired action.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC