Im using a PHP to validate and then update a registration system DB...
However, this next piece of code is not working how i want it to which is to first validate the proper USER ID syntax and then update the DB if the USER ID doesnt already exist.....
Butta
<?php
if (isset($HTTP_POST_VARS[Submit])) { // If the form was submitted, process it.
// Check the userid.
if (eregi ("[[:alnum:]]+$", $HTTP_POST_VARS[userid])) {
$a = TRUE;
} else {
$a = FALSE;
echo "<tr>\n"
."<td colspan=2 class=req align=center>Please enter a username that consists only of letters and numbers.</td>\n"
."</tr>\n";
}
if ($a) {
$query = "SELECT * FROM $table3 where userid=$userid";
$row = @mysql_fetch_object($query, $Link);
if ($row) {
echo "<tr>\n"
."<td colspan=2 class=req align=center>That USER ID is already taken. Please select another.</td>\n"
."</tr>\n";
}
else {
$query2 = "INSERT into $table3 values ('0','0','0','0','0','0','0','0','0','0','0','0', '$HTTP_POST_VARS[userid]', '0')";
if (mysql_db_query ($query2, $Link)) {
echo "<tr>\n"
."<td colspan=2 class=req align=center>$HTTP_POST_VARS[userid] was successfully registered.</td>\n"
."</tr>\n";
}
else
echo "<tr>\n"
."<td colspan=2 class=req align=center>There was a problem adding $HTTP_POST_VARS[userid]. Please Contact the $admin.</td>\n"
."</tr>\n";
}
}
}