Jump to content

help on building a session.


co.ador

Recommended Posts

Thank you mikesta

 

your script will get the $_POST value and assign it to the $_SESSION variable.

 

is the below correct?

 

page2.php

 

<?php 
$strZipCode = isset($_REQUEST['frmSearch']['zipcode'])?$_SESSION['zipcode']= mysql_real_escape_string($_REQUEST['frmSearch']['zipcode']):'';?>

 

Above $strZipCode is equal to if isset then $_SESSION zipcode equal escaped $_REQUEST from the form zipcode?

 

hope that set up is correct thank you mikesta.

Link to comment
Share on other sites

1) You should not use $_REQUEST, as this can take values from $_POST/$_GET/$_COOKIE, if you use a form, use the proper $_POST. Using $_REQUEST just invites trouble

2) You never check the session value so a empty string is taken, if no $_POST is sent

$strZipCode = isset($_POST['frmSearch']['zipcode'])?$_SESSION['zipcode']= mysql_real_escape_string($_POST['frmSearch']['zipcode']):(isset($_SESSION['zipcode'])?$_SESSION['zipcode']:'');

 

check the POST, check the SESSION, otherwise, leave as ''

 

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.