YaWK  24.1
Yet another WebKit
check-username.php
Go to the documentation of this file.
1 <?php
2 /* check if email is already registered */
3 if (!empty($_POST['newUsername']))
4 {
5  include '../../../classes/db.php';
6  $db = new \YAWK\db();
7  $request = $db->quote($_POST['newUsername']);
8  if ($res = $db->query("SELECT username FROM {users} WHERE username = '".$request."'"))
9  { // fetch data
10  $res = mysqli_fetch_row($sql);
11  if($res[0])
12  { // count result
13  $i = count($res[0]);
14  if ($i === 0)
15  { // username is free and not yet registered
16  echo "false"; die;
17  }
18  else
19  { // username is already in database
20  echo "true"; die;
21  }
22  }
23  else
24  { // username is already in database
25  echo "true"; die;
26  }
27  }
28  else
29  { // q failed
30  echo "true"; die;
31  }
32 }
33 else
34 { // get var is invalid
35  echo "true";
36 }
die
Definition: block-user.php:27
$sql
Definition: message-new.php:32
$i