<?php
$pages = array(
'track', 'account'
);
//loop over the pages and create the links if you want them to display like a list
//foreach($pages as $page){
// echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$page.'">'.$page."</a><br />\n";
//}
//if a link was clicked
if(!empty($_GET['page'])){
//check the page requested is a valid one
if(in_array($_GET['page'], $pages)){
$callfunc = $_GET['page'];
$callfunc();
} else {
echo 'Invalid page request';
}
} else { //no link was clicked so display the default page
track();
}
//User enters tracking number.
function track(){
echo '<form action="track.php?page=account" method="POST">
<p><font size="2" face="Tahoma">Please enter your 5 digit
tracking number to view your current account status.</font><br>
<input
type="text" size="25" maxlength="5" name="tracknumber"
style="background: white" style="border-color: black"
style="border-width: thin 1pt"> <input type="submit"
name="B1" value="Check Status" style="background: white"
style="border-color: black" style="border-width: thin 1pt"></p>
</form>';
}
//Gets the user order status
function account(){
//Get the tracking number the user provided.
$_GET["tracknumber"];
// replace these with your credentials
$database = "xxxxxxxxxxxxxxxx";
// Connect to Server
mysql_connect("localhost", "xxxxxxxxxxxx", "xxxxxxxxx") or die(mysql_error());
// Select Database
mysql_select_db($database) or die(mysql_error());
// Query the Database
$query = mysql_query("SELECT * FROM order WHERE tnumber = . $tracknumber ."); // replace table with your table name
if($query) {
while($row = mysql_fetch_row($query)) { // put results into an array
echo "Tracking Number Generated: " . $row["date"] . "<br>";
echo "Tracking Number: " . $row["tnumber"] . "<br>";
echo "Dedicated Server Package: " . $row["server"] . "<br>";
echo "Order Status: " . $row["status"] . "<br>";
// close the while loop
}
}else{
echo 'Sorry the tracking number you provided does not exist!';
}
}
?>
I dont know whats wrong... my query wont do anything with the database it wont check if the tracking number exists... the form input name is tracknumber.. how can i fix this problem? date is the date in which the tracking number was created, tnumber is the tracking number, server is the package they ordered, status is the status of their order...
I made some changes and the thing still returns tracking number does not exist... and i have a mysql_fetch_row error