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