Hey Everyone.
Im using jquery's Validation plugin to check post values before I submit a form. Im trying to check a mysql table column to match user name to check for a duplicate name before submitting.
This snippet of code below works as expected..
<?php
$request = trim(strtolower($_REQUEST['login']));
//sleep(2);
usleep(150000);
$users = array('asdf', 'Peter', 'Peter2', 'George');
$valid = 'true';
foreach($users as $user) {
if( strtolower($user) == $request )
$valid = 'false';
}
echo $valid;
?>
Im just wondering how I could get mysql results into that array there.
Ive tried something like below..
$request = trim(strtolower($_REQUEST['login']));
//sleep(2);
usleep(150000);
$users = array( );
$query = mysql_query("SELECT login FROM members");
while ($row = mysql_fetch_array($query))
{
$memberlogin = mysql_real_escape_string(trim($row['login']));
$users[] = $memberlogin;
$valid = 'true';
foreach($users as $user)
{
if( strtolower($user) == $request )
$valid = 'false';
}
echo $valid;
}
If someone can help thanks very much in advance.