Jump to content

[SOLVED] session problem


SirChick

Recommended Posts

I have a session issue with my scripts... i put sessions on pages like this:

 

$_SESSION['referer'] = $_SERVER['SCRIPT_NAME'];

  this is in estateagents.php

 

 

stop people clicking urls like /process.php

 

which would cause the process to run when accessed so i decided to put this in my process page :

 

if (isset($_POST['SellHouse']) && $_SESSION['referer'] == 'estateagents.php'){
do code}else{
$_SESSION['referer'] = 'invalid';
header("location: estateagents.php");
}

 

 

but it is not working .. it just headers every time rather than doing the code..

Link to comment
Share on other sites

it equals estateagents.php

and the $_POST['SellHouse']

 

is from this line :

 

<input type="submit" id="Button10" name="SellHouse" value="Sell my house!" style="position:absolute;left:250px;top:150px;width:142px;height:24px;z-index:13">
</form>

 

 

so it must be set otherwise it would'nt redirect...

Link to comment
Share on other sites

How about you modify your code slightly for a minute and see. Change it to this :

if (true && $_SESSION['referer'] == 'estateagents.php'){
   echo "OMG, both my tests evaluated to true";
}else{
  // Redirect another page.
  $_SESSION['referer'] = 'invalid';
  header("location: estateagents.php");
}

 

I think you'll find that may well work.

 

Link to comment
Share on other sites

What you're trying to stop is someone just typing the URL directly into their browser right?

 

So if they type it into their browser answer me these questions :

 

1) Are they performing a POST action?

2) If they are what does isset($_POST['SellHouse']) equal?

3) If they are NOT what does isset($_POST['SellHouse']) equal?

4) What is FALSE && TRUE?

5) What is FALSE && FALSE?

6) What is TRUE && TRUE?

Link to comment
Share on other sites

true and true = do the form processing .. else header away from it.

 

you hit the nail on the head with what im trying to do.

 

Basically say the url was changed to process.php

and the session had not been set yet then that suggests the user skipped the form data input..

 

 

i tested it by actually doing the form and hitting submit and it headers away when it should not.

the form is post.

 

Just tried this :

if (true && $_SESSION['referer'] == '/estateagents.php'){

 

i tried it with a / and with out the / encase it carried that with it but the echo didn't show... which suggests the session is not being created... but i don't see why as the session creation is right at the bottom of my form page outside of all the ifs etc

 

how ever when i echo this $_SESSION['referer'] = $_SERVER['SCRIPT_NAME']; it definitely shows /estateagents.php

 

just for extra prove encase im wrong here i provided a print screen of my page source:

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

I had an issue once using if( this && that ), couldn't get anything to work right, ended up trying to encase both in ()'s ie:

if( (this) && (that) )

was the only thing I could do to get both to evaluate properly. I can only suggest trying, cause it may just have been the way I had everything set up.

 

-Backu Zethara

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.