Hi member, am creating a shipping website with tracking page but I have problem with my php coding. I want only the tracking number entered into the tracking page to run MySql record on the database but with the code below, even any number i input or even with no input on the track page, would still run the database. Please I need help on...only the tracking number can run the record on MySQl. If my coding is wrong..pls correct me.
<html>
<body>
<?php
//Connect To Database
$hostname='foo.example.com';
$username='foo';
$password='password';
$dbname='ee456874958my';
$usertable='3456746my';
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
//This array contains all correct tracking numbers
$correct_tracking_numbers=array(22333);
if(in_array(22333,$correct_tracking_numbers)){
$query = 'SELECT * FROM ' . $usertable;
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['Date/Time'] . " " . $row['Event']. " ". $row['Location']. " " . $row['Details'] . "<br/>";
}
}else{
echo '<b>The tracking number you entered is not valid!</b>';
}
?>
</body>
</html>
Thanks all for reading and would appreciate a reply and help.