[nycphp-talk] Error Trapping Code problem
Kristina Anderson
ka at kacomputerconsulting.com
Wed Jun 4 18:32:28 EDT 2008
Hi everyone, this is probably something really dumb that I am missing,
but I need help. This code upon submit calls this error trapping
function (to test for duplicate usernames). There is a hidden field
named "step" that has a value of "1".
It is working on another page but I am trying to use this code and
apparently leaving something out?
Thanks for any help.
$step = isset($_POST['step']) ? $_POST['step'] : 0;
$username = isset($_POST['username']) ? $_POST['username'] : '';
$error = '';
switch ($step)
{
case 0; // do nothing, drop through and get user data
break;
case 1: // the user has submitted data, now check it.
//if ($error =='')
// {
$query = "SELECT * FROM Providers WHERE
username='$username' ";
echo $query;
$result = mysql_query($query) or die(mysql_error());
$myrow = mysql_fetch_assoc($result);
if (!empty($myrow))
{
$error = "Sorry, this username is already
taken";
}
// }
//break;
}
-- Kristina
More information about the talk
mailing list