I wrote this script where you go to localhost/censor.php/query and it sees if it is taken. Here is the code:
<?php
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return $pageURL;
}
$test = curPageURL();
$test = str_replace('http://localhost/censor.php/',"",$test);
$con = mysqli_connect("localhost","root","creepers2","spider");
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$usname = null;
$result = mysqli_query($con, "SELECT * FROM main WHERE urls='$test'");
while($row = mysqli_fetch_array($result) or die(mysqli_error($con))) {
$usname = $row['urls'];
if ($usname=$test)
echo "Taken!";
else
echo"YEAH!";
}
mysqli_close($con);
?>
If you to localhost/censor.php/queryinthedatabase it prints out taken. However, if you go to localhost/censor.php/querynotinthedatabase, it prints nothing. Help please?