Jump to content
xisto Community
Sign in to follow this  
electriic ink

Determining Whether A Phrase Is In A Variable deciding whether a string is a url

Recommended Posts

I have a input box in a form called "button" and when the user clicks Submit! I want php to determine whether or not this is a url or just text.All urls have "http://forums.xisto.com/; in them so I have decided I need a script which can determine whether or not "http://forums.xisto.com/; is in a variable or a string. The problem with using strings is that I've never needed to use them before (and thus have no knowledge about them).When I was using asp, I knew there was a function called instr() but I can't find php's equivalent. Does anybody know?Thanks in advance!

Share this post


Link to post
Share on other sites

Here, use something i came up with for my old website.

$name = $_POST['name'];$site = $_POST['site'];if(!$name || !$site){echo "You did not fill out the entire form.";exit;}else if($name && $site && (!ereg("^http://", $site) && (!ereg(".com$", $site) xor !ereg(".org$", $site) xor !ereg(".net$", $site)))){echo "You did not enter http:// and one of the following domain extensions: .com, .net, .org; in the url.";exit;}else if($name && $site && (ereg("^http://", $site) && (!ereg(".com$", $site) xor !ereg(".org$", $site) xor !ereg(".net$", $site)))){echo "You did not enter one of the following domain extensions: .com, .net, .org; in the url.";exit;}else if($name && $site && (!ereg("^http://", $site) && (ereg(".com$", $site) xor ereg(".org$", $site) xor ereg(".net$", $site)))){echo "You did not enter http:// in the url.";exit;}else if($name && $site && (ereg("^http://", $site) && (ereg(".com$", $site) xor ereg(".org$", $site) xor ereg(".net$", $site)))){[insert coding here]}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.