Forum Moderators: coopster

Message Too Old, No Replies

Returning a 404 when a variable is wrong

         

internetheaven

8:03 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Had a cms script created by a new firm who have disappeared and I'm left trying to finish it. I'm sure there is a resolution to this problem, I just can't find it:

If you access /example.php?ID=3&cat=2 then the right stuff shows up. But, if you access using any varible a page will show, it will just be blank (i.e. just the cms template and no content) e.g.

/example.php?ID=1498&cat=fudgcicals
/example.php?widgets
etc.

Is there some code you can put in the example.php script that says "if this does not exist in the database, then return a 404 error and go to this page: /error.php"

Thanks
Mike

whoisgregg

9:27 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll want to use the header function [php.net] to send 404 headers. Just make sure you call that function before any output is sent to the browser.