Jump to content

[SOLVED] $typ equals 99 but if ($typ >= 99) does not work, pointers please.


Bisa

Recommended Posts

I'm tired, and thus I am probably overlooking something here...

any way, my index.php looks like this:

 

	//Secure the get variables and forces them to be integers only
$typ = (int) secureFormInput($_GET["typ"]);
$mat = (int) secureFormInput($_GET["mat"]);
$do = (int) secureFormInput($_GET["do"]);

echo $typ . ' typ index <br />';

//Checks what the user wants to do based on the get variables
if ($do >= 1)
{
	if ($do == 1)
		include("om.php");
	elseif ($do == 3)
		include ("kontakt.php");
}
elseif ($typ >= 1)
	include("produkter.php");
else
	echo "Välkommen, bläddra gärna bland våra smycken i menyn till vänster.";

 

If go to the page using the url /index.php?typ=99 it does not include the produkter.php as I want it to do but I know by the echo $typ . ' typ index <br />'; that $typ is equal to 99. What am I missing here, any pointers to help out would be appreciated.

thing is, when I use /index.php?typ=99 there is no &do=3 or whatever number, it's not set thus would become 0 and be skipped by $do >= 1 or am I wrong?

 

Edit*

Explanation: There is no value in $_GET['do'] hence

$do = (int) secureFormInput($_GET["do"]);

would set $do equals 0

echoing $do confirms my suspicion that $do equals 0 and no, it does not get as far as else since the only thing I see on the screen is

 

99 typ index

0 do index

 

(just to make sure I added echo "hello world"; at the beginning of produkter.php but nothing was printed)

 

Edit*

var_dump($typ) and $do returns int(99) and int(0)

Notices aside, the following code works perfectly on my system.

 

<?php

$typ = (int) $_GET['typ'];
$mat = (int) $_GET['mat'];
$do = (int) $_GET['do'];

if ($do >= 1)
{

if ($do == 1)
	echo 'include("om.php")';
elseif ($do == 3)
	echo 'include ("kontakt.php")';

}
elseif ($typ >= 1)
echo 'include("produkter.php")';
else
echo "Välkommen, bläddra gärna bland våra smycken i menyn till vänster.";

?>

That code works for me as well as I get the echo printed about including, and yes, using the url /index.php?do=x will successfully include om.php or kontakt.php .... this is just weird  ???

 

(I checked the file name on produkter.php just to make sure but yea the file exists and has that name)

thank god  ;D

 

I included the config file on each page pretty much, in the config file I have the secure form function, the problem with this was when I load index.php I defined the function, when I then included produkter.php I did a new include of config and thus tried to define the function again -> FATAL ERROR!  :P

 

u learn something new every day, sorry to take your time with this, I'll make sure to have errors enabled from now on  ::)

Archived

This topic is now archived and is closed to further replies.

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