> $Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
> $Replace = "<a href=\"http://\\2\\3\"; target=\"_new\">\\2\\3</a>";
> $Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
> 
> print ("Your submission--$Array[URL]--has been received!<BR>\n");

That does no checking or validation at all. It simply tries to replace a
pattern with another one. If the pattern isn't matched, then the
original string is returned unchanged. 

If you want to validate the entry, then check to see if string has
changed at all.

$Pattern = "(http://)?([^[:space:]]+)([[:alnum:]\.,-_?/&=])";
$Replace = "<a href=\"http://\\2\\3\"; target=\"_new\">\\2\\3</a>";
$temp = $Array["URL"];
$Array["URL"] = eregi_replace($Pattern, $Replace, $Array["URL"]);
if(strcmp($temp,$Array["URL"])==0)
{ echo "You did not enter a good URL address."; }

---John Holmes...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to