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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

?>

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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  ::)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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

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.