Hi guys,
I have tried my efford to solve this problem but still not found my coding error.
I want user to enter their product S/N and check whether their product is registered product or not. If it match our list, i will update their status to registered user. Here are my codes:
<?php
include("../../reg/library/db.php");
?>
<?php
if(@$_GET['sn'] == "process")
{
$sql = "SELECT * FROM skey";
$result = mysql_query($sql);
$r = mysql_fetch_array($result);
$reg_sn = $r["serial_number"];
$status = $r["status"];
//check form for errors
$serial = ( (isset($POST['serial_number'])) ? $POST['serial_number'] : '');
if (!ereg ("[0-9]{19}$",$serial) || $serial == '' )
{
echo "Your serial number is invalid<br>
Please enter again.<br><input type=button value='Back' onClick='history.go(-1)'>";
}
elseif ( $serial != $reg_sn)
{
echo "Your sKey serial number does not match our record. Please try again or contact your source.";
}
elseif ( $serial == $reg_sn && $status == '2')
{
echo "Your sKey was already registered! Please contact your source.";
}
else
{
$sql = "UPDATE skey SET status='2' WHERE serial_number = '$serial'";
if( !$result = mysql_query($sql, $db_link) )
{
die('Error inserting new data: ' . mysql_error());
}
echo "<center>Your serial number has been submitted.<br>
Your registration is not finish yet! Please click button below to go to the next step.";
echo "<form method='POST' action='uinfo.php'><table class='bodytable'>
<tr><td class='bottomform'> <input type='submit' value='Step 3'> </td></tr></table></form></center>";
}
mysql_close($link);
}
else
{
echo "<hr>";
echo "<center><u> Enter Your sKey Serial Number</u><br>
<table class='bodytable'><form method='POST' action='".$_SERVER['PHP_SELF']."?sn=process'>
<tr><td class='cap'>sKey Serial Number:</td>
<td class='bottomform'> <input type='text' name='serial_number' size='20' value='$serial_number' maxlength='19'> </td></tr>
<tr><td></td><td colspan='2'><br><input type='submit' value='Submit'></td></tr>
</table></center>";
echo "<hr>";
}
?>
The problem are:
1. when they submit, wrong SN, it says that it is already registered.
2. If they enter right SN, it still says it is already registered & it does not update the status.
Thanks for help.