$result = @(
"INSERT INTO logins"
. " (name, clearpass, cryptpass, access)"
...
Why are you saving the plaintext password? There's no point
saving the md5 hash if you also have the plaintext available.
But of course the more secure thing is to save just the hash.
if ($result)
{
echo "$user_name was added.<br>";
}
if (!$result)
This should be <b>else</b>; having two mutually-exclusive
if's in a row might give the same effect, but it's quite harmful
to the reader who is trying to understand the intent of your
code.
{
if (mysql_errno() == "1062")
{
echo "Sorry, $user_name is already taken."
. "Please choose another name.<br>";
}
else
{
echo "Something bad happened: " . mysql_error();
}
else
{
// our nasty little else
}
}
}
This last <b>else</b> should just go away; it doesn't represent
anything that should happen.
One improvement on the above might be to use <b>elseif</b> to
flatten out the nesting:
if ($result)
{
echo "$user_name was added.<br>";
}
elseif (mysql_errno() == "1062")
{
echo "Sorry, $user_name is already taken."
. "Please choose another name.<br>";
exit;
}
else
{
echo "Something bad happened: " . mysql_error();
exit;
}
I've added <b>exit</b> to the elseif and else to emphasize that you
wouldn't go further in the script, the user needs to go back and choose
another name.