i m trying to display a message based on code status against the code in the database for on the code entered.
however it gives me a parse error
however it gives me a parse error
Code:
<?php require_once("includes/functions.php"); ?>
<?php
// Database Constants
define("DB_SERVER", "localhost");
define("DB_USER", "tara");
define("DB_PASS", "tara");
define("DB_NAME", "book");
?>
<?php
// 1. Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
die("Database connection failed: " . mysql_error());
}
// 2. Select a database to use
$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
?>
<?php
include_once("includes/form_functions.php");
// START FORM PROCESSING
if (isset($_POST['submit'])) { // Form has been submitted.
$code = trim(mysql_prep($_POST['code']));
$count_code = 0;
// checks database for the code for errors
$result_code = mysql_query("SELECT code FROM orders WHERE code = '{$code}' " );
confirm_query($result_code);
if (mysql_num_rows($result_code) == 1)
{
$count_code = $count_code + 1;
}
// checks database for the status for errors
$result_codestatus = mysql_query("SELECT codestatus FROM orders WHERE code = '{$code}'");
confirm_query($result_codestatus);
if (mysql_num_rows($result_codestatus) == 1)
{
if ($result_codestatus=="P"){
$message = " Your status is pending";
}
if ($result_codestatus=="W"){
$message = " Your status is waiting"; }
if ($result_codestatus=="A"){
$message = " Your status is approved";
}
}
else
{// Code does not existing
$code = "";
$message = " Your code doesn't exist";
}
?>
<html>
<head>
<title>sitename</title>
<link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1>sitename</h1>
</div>
<div id="main">
<table id="structure">
<tr>
<td id="navigation">
<a href="welcome.php">Return to Menu</a><br />
<br />
</td>
<td id="page">
<h2>Login</h2>
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<?php $code = ""; ?>
<form action="status.php" method="post">
<table>
<tr>
<td>Enter Code:</td>
<td><input type="text" name="code" maxlength="40" value="<?php echo htmlentities($code); ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Check" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
<div id="footer">Copyright 2010</div>
</body>
</html>
<?php
// Close connection
mysql_close($connection);
?>
Comment