eschuppe
03-09-2009, 12:22 AM
I've located source of the error but i'm not exactly sure what I need to do fix it. Any advice is much appreciated.
Thanks,
Eric
<?php
session_start();
include ('dbc.php');
if ($_POST['Submit'] == 'Register')
{
if (strlen($_POST['user_idnum']) > 4)
{
header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
}
if (strlen($_POST['bookisbn']) < 4)
{
header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
}
// Error Starts here
if ($_POST['user_idnum'] && $_POST['bookisbn']) { // If everything is okay.
$query = "SELECT user_idnum FROM users";
$result = @mysql_query ($query); // Run the query.
if (mysql_fetch_object($result) == $_POST['user_idnum']) {
// Make the query.
$query = "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$_POST[user_idnum], 'NOW()', '$_POST[bookisbn]')";
$result = @mysql_query ($query); // Run the query.
if ($result) {
// Send an email.
echo '<p><b>You have been registered!</b></p>';
exit(); // Quit the script.
} else { // If it did not run okay.
echo '<p>You could not checkout a book due to a system error. We apologize for any inconvenience.</p><p>' . mysql_error() . '</p>';
}
} else {
echo '<p>Your id number does not match.</p>';
}
mysql_close(); // Close the database.
} // End the conditionoal.
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
<p> </p>
<table width="65%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Register Account</font></strong></td>
</tr>
<tr>
<td bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="checkout.php" style="padding:5px;">
<p><br>
ID Number:
<input name="user_idnum" type="text" id="user_idnum">
</p>
<p>
Book:
<input name="bookisbn" type="text" id="bookisbn">
</p>
<p align="center">
<input type="submit" name="Submit" value="Register">
</p>
</form></td>
</tr>
</table>
<div align="left"></div>
</body>
</html>
Thanks,
Eric
<?php
session_start();
include ('dbc.php');
if ($_POST['Submit'] == 'Register')
{
if (strlen($_POST['user_idnum']) > 4)
{
header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
}
if (strlen($_POST['bookisbn']) < 4)
{
header("Location: checkout.php?msg=ERROR: Incorrect Student ID. Please enter valid ID number.");
}
// Error Starts here
if ($_POST['user_idnum'] && $_POST['bookisbn']) { // If everything is okay.
$query = "SELECT user_idnum FROM users";
$result = @mysql_query ($query); // Run the query.
if (mysql_fetch_object($result) == $_POST['user_idnum']) {
// Make the query.
$query = "INSERT INTO checkout (full_name, user_idnum, date, book) VALUES ('$_POST[user_idnum], 'NOW()', '$_POST[bookisbn]')";
$result = @mysql_query ($query); // Run the query.
if ($result) {
// Send an email.
echo '<p><b>You have been registered!</b></p>';
exit(); // Quit the script.
} else { // If it did not run okay.
echo '<p>You could not checkout a book due to a system error. We apologize for any inconvenience.</p><p>' . mysql_error() . '</p>';
}
} else {
echo '<p>Your id number does not match.</p>';
}
mysql_close(); // Close the database.
} // End the conditionoal.
}
?>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
<p> </p>
<table width="65%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="d5e8f9" class="mnuheader"><strong><font size="5">Register Account</font></strong></td>
</tr>
<tr>
<td bgcolor="e5ecf9" class="forumposts"><form name="form1" method="post" action="checkout.php" style="padding:5px;">
<p><br>
ID Number:
<input name="user_idnum" type="text" id="user_idnum">
</p>
<p>
Book:
<input name="bookisbn" type="text" id="bookisbn">
</p>
<p align="center">
<input type="submit" name="Submit" value="Register">
</p>
</form></td>
</tr>
</table>
<div align="left"></div>
</body>
</html>