Jump to content

[SOLVED] How to query database if ...


dhimok

Recommended Posts

Hello, I have a question if u might help me.

 

I want to redirect to error page if trying to enter a page or article where id does not exist or is deleted.

Let s say that the last record is 30 and if someone tries to abuse the site and enters ?c=60. The db query of course does not find any records. So how can I query the database and send them somewhere else if this happens?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/45885-solved-how-to-query-database-if/
Share on other sites

You just check to see if what they entered in the URL is fixed or not...

 

<?php

$c = $_GET['c'];

$sql = mysql_query("SELECT col1, col2 FROM table WHERE c='$c'"):

   if (mysql_num_rows($sql) <= 0){
      //redirect them
   } else {
      //display page information
   }

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.