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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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']);

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.