Jump to content


Photo

Hellpp


  • Please log in to reply
10 replies to this topic

#1 Short-URL

Short-URL
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 27 August 2006 - 10:16 PM

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?

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 August 2006 - 10:25 PM

if (strpos($shorturl,array("/",".")) {
  echo "your shorturl cannot contain slashes or full stops";
}


#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 August 2006 - 10:30 PM

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:
<?

//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);


?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 Short-URL

Short-URL
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 27 August 2006 - 10:41 PM

thorpe, that code doesnt seem to work. It seems to bypass it..

#5 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 August 2006 - 10:42 PM

thorpe, that code doesnt seem to work. It seems to bypass it..


Sorry... try.

if (strpos($shorturl,array("//",".")) {


#6 Short-URL

Short-URL
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 27 August 2006 - 10:46 PM

Still nothing..

if (strpos($shorturl,array("//","."))) {

you missed a bracket off the end.. so I added it on but it still doesnt work.


#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 August 2006 - 12:33 AM

why do you get an error please tell us if you use a dot or slash?
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 Short-URL

Short-URL
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 28 August 2006 - 10:55 AM

Hello,

I have tried using the above, but it still lets me signup with a dot or a slash.

#9 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 28 August 2006 - 10:59 AM

What charaters you consider as valid? Only alphanumeric? Or other stuff too?

Orio.
Think you're smarty?

(Gone until 20 to November)

#10 Short-URL

Short-URL
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 28 August 2006 - 11:59 AM

alphanumeric.

#11 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 28 August 2006 - 12:09 PM

Use:
<?php
if(!ereg("^[a-zA-Z0-9]+$", $url)){
die("Invalid url");
}
?>

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users