Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created June 16, 2010 13:47
Show Gist options
  • Select an option

  • Save thinkphp/440705 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/440705 to your computer and use it in GitHub Desktop.
<?php
if(isset($_GET['username']) && $_GET['username']!="") {
require_once("config.php");
$username = $_GET['username'];
if(!$handler = mysql_connect($host,$user,$pass)){
throw new Exception(mysql_error($handler));
}
if(!mysql_select_db($db,$handler)){
throw new Exception(mysql_error($handler));
}
$query = "SELECT * FROM $table WHERE username='".mysql_real_escape_string($username)."'";
$results = mysql_query($query);
if(mysql_num_rows($results) > 0) {
echo"0";
}else {
echo"1";
}
}
if(isset($_GET['ajax'])) {
exit();
}
mysql_close($handler);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment