Troubleshooting multiple GET variables In PHP
- by V413HAV
This may be a very simple question but I don't what's the wrong thing am doing here...
To explain you clearly, I've set a real simple example below:
<ul>
<li><a href="test.php?link1=true">Link 1</a></li>
<li><a href="test.php?link2=true">Link 2</a></li>
<li><a href="test.php?link3=true">Link 3</a></li>
</ul>
<?php
if(isset($_GET['link1'])) {
if(($_GET['link1']) == 'true') {
echo 'This Is Link 1';
}
}
if(isset($_GET['link2'])) {
if(($_GET['link2']) == 'true') {
echo 'This Is Link 2';
}
}
if(isset($_GET['link3'])) {
if(($_GET['link3']) == 'true') {
echo 'This Is Link 3';
}
}
?>
This is a test.php page, here I've set 3 different arguments for $_GET, and show contents accordingly, now everything works perfect, the only thing am not understanding is how to block this kind of url say
if user clicks on link 1 the url will be :
http://localhost/test.php?link1=true
And the Output of this url is This is Link 1
Now if I change this url to :
http://localhost/test.php?link3=true&link2=true&link1=true
And the Output what I get is This Is Link 1This Is Link 2This Is Link 3
Now this is ok here, but it's very annoying if someone types this and see's forms one below the other, any way I can stop this tampering?