Jump to content

What is wrong with this code?

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



Link to post
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 post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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