JJBlaha Posted December 17, 2006 Share Posted December 17, 2006 I want to have a user input their website, and if they do not put http:// before it, i want the script to add it. If they did put it, then i want it unchanged. For example an input of www.phpfreaks.com should output as http://www.phpfreaks.com. Anyone know how to do this? Link to comment https://forums.phpfreaks.com/topic/31026-website-input-form-question/ Share on other sites More sharing options...
matto Posted December 17, 2006 Share Posted December 17, 2006 combination of if, substr(), and substr_replace() should do the trick Link to comment https://forums.phpfreaks.com/topic/31026-website-input-form-question/#findComment-143181 Share on other sites More sharing options...
JJBlaha Posted December 18, 2006 Author Share Posted December 18, 2006 could you give me an example of how that might look? i have never used substr or strstr before. Link to comment https://forums.phpfreaks.com/topic/31026-website-input-form-question/#findComment-143231 Share on other sites More sharing options...
chiprivers Posted December 18, 2006 Share Posted December 18, 2006 <?phpif(substr($string,0,7) = "http://") { // leave $string as is} else { $string = "http://".$string;}?> Link to comment https://forums.phpfreaks.com/topic/31026-website-input-form-question/#findComment-143248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.