Answer by
rover (53)
Assuming your database has a nickname field, you can query the database using PDO as such:
$dsn = 'mysql:dbname=mydb;host=127.0.0. 1'; /*using mysql, for example*/
$user = 'yourusername';
$password = 'yourpass';
$dbh = new PDO($dsn, $user, $password);
$sql = "SELECT COUNT(*) FROM mytable WHERE nickname =? ";
$stmt = $dbh->prepare($sql);
$result = $stmt->execute(array('nicknametofind'));
$result->fetch();
if ($result[0] > 0){
//the nickname exists
}