Jump to content

Details display even if category is types wrong in url


$php_mysql$

Recommended Posts

friends my url is like this

 

Category=Love&ID=1

 

now in url if i do something like this

 

Category4637=Hate19203&ID=1

 

the details are still showing, how can i fix this? if someone type Capegory instead of Category and a wrong category name which do not exist with that id in db send them to index.php?

oh i was grabbing it like this

 

$cat = clean($_REQUEST['Category']);

$ID = clean($_REQUEST['ID']);

 

and for querying the database i made a function and i fetch it by the id which come along with the url

 

 

over all it looked like this

 

$cat = clean($_REQUEST['Category']);

$ID = clean($_REQUEST['ID']);

$details = getDetails($ID);//  the query in the function is like  select from tbl as d where d.id=$ID

Your question was:

now in url if i do something like this

 

Category4637=Hate19203&ID=1

 

the details are still showing, how can i fix this?

 

so yes, since you're only using the ID=1 to grab the results, the other variable is not doing anything.

ok help required

 

how am i to check if $cat = clean($_REQUEST['Category']);  which is Love as in Category=Love?ID=1  the name Love exist in database with the following id 1?

 

the db structure is like

 

id

image

title

category

time

 

$cat = clean($_REQUEST['Category']); 

$ID = clean($_REQUEST['ID']);

 

your question was:

how am i to check if (...) the name Love exist in database with the following id 1?

 

The code I gave you search for rows where id=$id and category=$cat... so, if there's no match, it will return empty.

ah solved solution

 

my function

 

////////////////////////////////////Check

function detailsCheck($id) {

$id = "";

$sql =" SELECT category FROM tbl WHERE  id='$id'";

$rs = executeSql($sql);

$id = mysql_fetch_array($rs);

return $id[0];

}

 

and did a check

 

if(detailsCheck($ID) !== $cat){

header("location: index.php");

}

 

:-) cheers, thanks again \m/

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.