Jump to content

What is wrong with this code?


egenart

Recommended Posts

I have heavily relied upon register_globals in my web projects since years back.

So, now when this function is turned off I'm trying the GET method.

But I haven't found anywhere how I use this to pass variables through the URL from clicking a link.

 

Here is an example of my code:

 

<? if ($_GET["pageid"]="igbestallning") {

include "includes/igbestallning.inc.php";

}

elseif ($_GET["pageid"]="dialog") {

include "includes/dialog.inc.php";

}

elseif ($_GET["pageid"]="forslum") {

include "includes/forslum.inc.php";

} else {

include "includes/nospam.inc.php";

}

?>

In this case I get the page "includes/igbestallning.inc.php" independent of which link I click.

If I click the link http://www.gestaltinformation.se/500_dialog.php?pageid=dialog I still get the first alternative.

I'm no programmer, so I try to keep things simple as long as I can understand how to make things happen. This problem eludes me, though.

I appreciate any suggestions...

Regards,

Lars

Link to comment
Share on other sites

You are using "=" when you should be using "==" or "===". The "=" operator is for setting a value, == and === are for comparing values.Your code could probably be a little easier to manage if you used a switch statement instead:

switch ($_GET["pageid"]) {  case 'igbestallning':  case 'dialog':  case 'forslum':    include "includes/{$_GET['pageid']}.inc.php";    break;  default:    include "includes/nospam.inc.php";    break;}
That way you only need to add 1 line if you have another page to add.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...