Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking if Username already exists
    primarykey
    data
    text
    <p>I currently have this code that I wrote up:</p> <pre><code>$username = $_POST['username']; $password = $_POST['password']; $rpassword = $_POST['rpassword']; $usrip = $_SERVER['REMOTE_ADDR']; $email = $_POST['email']; $errors = array(); $checkUsername = $odb -&gt; prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username"); $checkUsername -&gt; execute(array(':username' =&gt; $username)); $countUsername = $checkUsername -&gt; fetchColumn(0); if ($checkUsername != 0) { $errors['Username is already taken']; } </code></pre> <p>However it seems to just completely ignore this and even if the username is identical (capitals and such) it will still allow the user to register making 2 of the same users. My database looks like this:</p> <p><a href="http://puu.sh/1mTcZ/9b2ff3b68f44b4cc486beacc2d2b88fd" rel="nofollow">http://puu.sh/1mTcZ/9b2ff3b68f44b4cc486beacc2d2b88fd</a></p> <p>I cant seem to get this working at all. The database structure looks like this: refined (dbname) > users (table) > username (row)</p> <p>Any help is very much appreciated.</p> <p>Edit:</p> <p>After a few changes this is what I have, however I still seem to be having the same issues.</p> <pre><code>$checkUsername = $odb-&gt;prepare("SELECT COUNT(*) FROM `users` WHERE LOWER(`username`) = :username"); $checkUsername -&gt; execute(array(':username' =&gt; $username)); $countUsername = $checkUsername -&gt; fetchColumn(0); if ($checkUsername != 0) { $errors['Username is already taken']; } </code></pre> <p>The username row is also now utf8_general_ci</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload