Jump to content

Archived

This topic is now archived and is closed to further replies.

Short-URL

Hellpp

Recommended Posts

Okay, I have my website http://www.small-url.com

But I cant seem to figre out stopping someone signing up as there shorturl with a slash or a dot, becuase that causes errors

Any ideas?

Share this post


Link to post
Share on other sites
[code=php:0]
if (strpos($shorturl,array("/",".")) {
  echo "your shorturl cannot contain slashes or full stops";
}
[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[quote]thorpe, that code doesnt seem to work. It seems to bypass it..[/quote]

Sorry... try.

[code=php:0]
if (strpos($shorturl,array("//",".")) {
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
why do you get an error please tell us if you use a dot or slash?

Share this post


Link to post
Share on other sites
What charaters you consider as valid? Only alphanumeric? Or other stuff too?

Orio.

Share this post


Link to post
Share on other sites
Use:
[code]<?php
if(!ereg("^[a-zA-Z0-9]+$", $url)){
die("Invalid url");
}
?>[/code]

Orio.

Share this post


Link to post
Share on other sites

×

Important Information

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.