Code: Select all
/*this comes from the data entry form
$user_sn=strip_tags(trim($_POST['registration_id']));
/* Lets check to see if we have a valid serial number
/* I've tried formatting the query in several different ways
$query=sprintf("SELECT * FROM serial_numbers WHERE sd='$user_sn'" '
mysql_real_escape_string($user_sn));
$result=mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}else{
$num=mysql_num_rows($result);
echo $num;
die();
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['sd'];
echo $row['fn'];
}
/* at this point I want the program to go and tell the user there's no serial number on record
if ($num < 1){
header("Location:http://www.domain.com/sub-folder/bad_serial.html");
exit();
}
// Free the resources associated with the result set
mysql_free_result($result);
Code: Select all
/* Lets see if this login is in the database and if not then let's go ahead and create the user database */
$query="SELECT user_id FROM users WHERE user_id='$new_user'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
if ($num == 1){
header("Location:http://www.domain.com/sub-folder/usersetup.html");
exit();
}
else
{
/*query to insert new record into table
}