Jump to content

main.php?var=newsub


prudens

Recommended Posts

$type = $_GET['type'];
$id   = $_GET['id'];

if ($type == "aaa")
{
echo "Yes!";
}
elseif ($type == "ddd")
{
echo "none";
}

 

You had single = which mean if $type has been successfully set to "aaa" then echo yes! what you wanted is if $type already equal to aaa by using ==

 

by strip i mean if you are planning to echo back a variable from PSOT or GET then make sure you remove unsave charactors which can be used for injection and cross site linking.

 

regards

Liam

 

Regards

Liam

Link to comment
Share on other sites

addslashes() is a start as this will add backslashes to ' and " therefore stopping people from ending 1 eliment and starting another.

 

It all depends as to what your doing with the variables and also how secure your site needs to be.

 

for example i display status messages using switch

switch($_GET['status']) {
  case 1:
    echo 'Permissions denied'; 
  break;
  case 2:
    echo 'You are now logged in';
  break;
}

 

This means that im never actually echo'in the variable back and therefore no one can add extra code by somthing like the following.

 

http://somesite.com/login.php?status=<iframe src ="www.phpfreaks.com" width="100%"></iframe>

 

echo $status;

 

 

Hope this makes sence.

 

Reagrds

Liam

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.