Jump to content


redirection problem


3 replies to this topic

#1 ap_

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 09 December 2007 - 04:29 PM

i have this code:
<?php

$user = $_GET['id'];
$option = $_GET['opt'];

if($option = "info"){
	include('usdata.php');

}elseif($option = "upload"){
	require('doupload.php');
	die();

}

?>

and it just keep loading usdata.php only , any ideas?
I use both require() and include() fuctions and keep it doing the same.

The links are <a href="folder/?id=sm&opt=nn"></a>

Any help would be gratefull.

Thanks by the way!

Edited by ap_, 09 December 2007 - 04:33 PM.


#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 09 December 2007 - 04:41 PM

For one thing, this is not redirection, so I don't quite get why your title refers to it as that.

Your problem lies in the fact that you are not using the correct operators in your if/elseif statements. When you use one equal sign (=), you are assigning the variable a value, so this will (almost) always result in returning true, as long as the variable could be correctly set to that value, and that value doesn't evaluate to false. To compare, you need to use double equal signs (==).

So basically your code would be this.

<?php

$user = (int)$_GET['id'];
$option = $_GET['opt'];

if($option == 'info'){
	include('usdata.php');
}
elseif($option == 'upload'){
	require('doupload.php');
	die();
}

?>

Just simple stuff. :)

Edited by Demonslay, 09 December 2007 - 04:45 PM.


#3 dotbart

    Young Padawan

  • Members
  • Pip
  • 141 posts
  • Gender:Male
  • Location:Diepenbeek
  • Interests:Webdesign, Webdeveloppement, DJ, ...

Posted 09 December 2007 - 04:41 PM

you are using only one '=' in your if

wich assigns the value 'info' to $option

should be:
<?php

$user = $_GET['id'];
$option = $_GET['opt'];

if($option == "info"){
	include('usdata.php');

}elseif($option == "upload"){
	require('doupload.php');
	die();

}

?>


#4 ap_

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 09 December 2007 - 05:15 PM

thanks a lot ure the best.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users