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.

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

 

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.