Short-URL Posted August 27, 2006 Share Posted August 27, 2006 Okay, I have my website http://www.small-url.comBut I cant seem to figre out stopping someone signing up as there shorturl with a slash or a dot, becuase that causes errorsAny ideas? Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/ Share on other sites More sharing options...
trq Posted August 27, 2006 Share Posted August 27, 2006 [code=php:0]if (strpos($shorturl,array("/",".")) { echo "your shorturl cannot contain slashes or full stops";}[/code] Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81306 Share on other sites More sharing options...
redarrow Posted August 27, 2006 Share Posted August 27, 2006 you should sort the error out ok.when the error is sorted the example below to valadate url good luck.sorry there you go you can have http:// or www. or both lol full url or subdomain[code]Code:<?//tempary web address.$web_address="www.google.com";function web_address($web_address) {if(eregi("^(http://|www.)+[a-z]+\.+[a-z]+(\.+[a-z]{2})?$",$web_address)){echo "Correct web address!";}else{echo "Wrong web address!";} }//returning the function.web_address($web_address);?>[/code] Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81310 Share on other sites More sharing options...
Short-URL Posted August 27, 2006 Author Share Posted August 27, 2006 thorpe, that code doesnt seem to work. It seems to bypass it.. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81316 Share on other sites More sharing options...
trq Posted August 27, 2006 Share Posted August 27, 2006 [quote]thorpe, that code doesnt seem to work. It seems to bypass it..[/quote]Sorry... try.[code=php:0]if (strpos($shorturl,array("//",".")) {[/code] Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81318 Share on other sites More sharing options...
Short-URL Posted August 27, 2006 Author Share Posted August 27, 2006 Still nothing..if (strpos($shorturl,array("//","."))[color=red][b])[/b][/color] {you missed a bracket off the end.. so I added it on but it still doesnt work. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81321 Share on other sites More sharing options...
redarrow Posted August 28, 2006 Share Posted August 28, 2006 why do you get an error please tell us if you use a dot or slash? Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81369 Share on other sites More sharing options...
Short-URL Posted August 28, 2006 Author Share Posted August 28, 2006 Hello,I have tried using the above, but it still lets me signup with a dot or a slash. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81537 Share on other sites More sharing options...
Orio Posted August 28, 2006 Share Posted August 28, 2006 What charaters you consider as valid? Only alphanumeric? Or other stuff too?Orio. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81540 Share on other sites More sharing options...
Short-URL Posted August 28, 2006 Author Share Posted August 28, 2006 alphanumeric. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81556 Share on other sites More sharing options...
Orio Posted August 28, 2006 Share Posted August 28, 2006 Use:[code]<?phpif(!ereg("^[a-zA-Z0-9]+$", $url)){die("Invalid url");}?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/18839-hellpp/#findComment-81559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.