if i’ve input text where visitor should enter own URL
<form name="frm" method="post" action="addlink.php">
url : <input type="text" name="url" id="url">
<button type="submit" class="options green">add</button>
</form>
and addlink.php code like this
$url = $_POST['url'];
$sql = "INSERT INTO $table_urls (url) VALUES ('$url')";
mysql_query($sql, $conn) or die(mysql_error());
i want to ban for example http://www.something.com/anything so if the visitor enter any url has http://www.something.com/else – http://www.something.com/elsething ..etc
it detect something.com and gives error like
<?PHP if(XXXXXXXX){
echo "somthing.com is not allowed";
}else{
$sql = "INSERT INTO $table_urls (url) VALUES ('$url')";
mysql_query($sql, $conn) or die(mysql_error());
}
if what ! i wanna say if $url has any something.com then give not allowed !
You can use PHP’s function,
preg_match()to find the exact match:For more information on using that function, you can check here: http://php.net/manual/en/function.preg-match.php