We have a product catelog page which display product information basis database values
For Instance: If Product is:- a) soft toys, model is teddy bear (having id as 10) and submodel is between - cushion (300), nappa (301), soft(302)
b) soft toys, model is tiger (having id as 11) and submodel is between - asian (303), african (304)
Then we display information through url - as correct scenario
www.xxx.com/index.php?option=com_toys&view=product&id=10&sid=300 - Teddy bear cushion
www.xxx.com/index.php?option=com_toys&view=product&id=10&sid=301 - Teddy bear nappa
www.xxx.com/index.php?option=com_toys&view=product&id=10&sid=302 - Teddy bear soft
www.xxx.com/index.php?option=com_toys&view=product&id=11&sid=303 - Tiger Asian
www.xxx.com/index.php?option=com_toys&view=product&id=11&sid=304 - Tiger African
But - whats also seen that the page is displayed using wrong parameters of different submodel with wrong product
For exacmple
www.xxx.com/index.php?option=com_toys&view=product&id=10&sid=304 -
It shows wrong information as Teddy Bear African
or www.xxx.com/index.php?option=com_toys&view=product&id=11&sid=300
- It shows wrong information as Tiger Cushion
wherein in actual its wrong as such product page never exists (due to incorrect sid matching with product id) - but due to url are shown
How to put in 404 error through database if id and sid does not match ?
Are you looking for something like this?
$validOptions = getCategoryProducts($id);
if (!in_array($sid, $validOptions){
header('HTTP/1.0 404 Not Found');
echo "<h1>Product Not Found</h1>";
echo "The product that you have requested could not be found.";
exit();
}