I have several URL's that display random data from a database. I would like to know a better (more secure) way to display the data. Right now it uses the real table and column names and I would like to disguise them somehow. Here is the syntax of the URL:
<a href="fetch_page.php?cat=table&subcat=column">Link</a>
The difficulty is that the select statement uses order by rand, so I am not sure of a way to pull the record by the id. Here is the PHP code:
$category = $_GET['cat'];
$subcategory = $_GET['subcat'];
if($category=="")
{
header("Location: index.php");
} else {
if($subcategory=="")
$result=mysql_query("SELECT * FROM ".$category." ORDER BY RAND() LIMIT 1");
else $result=mysql_query("SELECT * FROM ".$category." WHERE Category LIKE '".$subcategory."' ORDER BY RAND() LIMIT 1");
$row = mysql_fetch_assoc($result);
$data=$row['column'];
header("Location: ".$data);
echo $data;
if (!mysql_num_rows($result));
echo "No records found";
}
Can someone please steer me in the right direction?