Click to See Complete Forum and Search --> : email or url?


putnamehere
04-09-2006, 10:35 AM
I'm makeing a comment script that has a inout box for email or url i need to define if it's a emil or a url so i can use the mailto:// and http:// acordingly.
the fact that people may also type www. adds to my head ache.

for example:
www.this.com
http://this.com
http://www.this.com
are all the same so i'v coem up with something but it dosent work.


if (strpos($_POST['email'], '@') !== false) {

$start = "mailto://";
} else {
$start = "http://";



$site = preg_match ("/$http/i", "$email");
$site1 = preg_match ("/$www/i", "$email");
$site2 = preg_match ("/http://www./i", "$email");
if ( $site )
{

$start = "";
}elseif ( $site1 )
{

$start = "http://";

}elseif ( $site2 )
{

$start = "";
}




}


what can i do to find out strip http://www. or maybe jsut www or even http:// ?

HeLp?

Zipline
04-09-2006, 11:22 AM
why dont you just check for http://

putnamehere
04-09-2006, 11:28 AM
I did try that origanaly the code above is like 1 of 5 things i ttyed.
What would you use the "check for http://"?

putnamehere
04-09-2006, 11:36 AM
<?
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST["myname"];

$email = stripslashes($email);
$email = strip_tags($email);
$email = trim($email);

$name = stripslashes($name);
$name = strip_tags($name);
$name = trim($name);


$comment = stripslashes($comment);
$comment = strip_tags($comment);
$comment = trim($comment);

$http = "http://";
$www = "www.";
$at = "@";

$website = strpos($email, $http);
$website1 = strpos($email, $www);
$isemail = strpos($email, $at);


if (strpos($_POST['email'], '@') !== false) {

$start = "mailto://";
} else {

if(strpos($_POST['email'], 'http://') !== false){

$start = "";

} else {
$start = "http://";
}

}







echo "$name <br> $email <br> $comment";


$write = "<font><a href=$start$email> $name </a> Say's:</font><br><div class=small> $comment </div><img src=line.jpg width=400>";




$file = 'show/rrcomments.txt';
$file = fopen ( $file, "a+") ;
fwrite ( $file, "
$write" ) ;
fclose ( $file ) ;

?>


EDIT: Nevermind it works now see above.