Re: Session and validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Chris Shiflett <shiflett@xxxxxxx> wrote:

> --- Stuart Felenstein <stuart4m@xxxxxxxxx> wrote:
> > I had this thread going yesterday. Then basically
> > think it reached a stalemate.
> 
> I think you need to try to simplify your code to the
> most basic example
> that demonstrates the problem. By doing this, you'll
> achieve one of two
> things:
> 
> 1. Figure out the problem yourself.
> 2. Generate a perfect example that we can use to
> better understand your
> problem and suggest a solution.
> 
Yes, this is exactly what I did and why I dredged up
this topic again:

Here is the example:

testarray (page1)
//Start the session
<?php session_start(); 

//Check for the array on submit
if ( empty( $_SESSION['l_industry'] ) ) {
$_SESSION['l_industry']=array();
}
//Check to make sure user didnt exceed 5 selections
if (count($industry) > 5) {
    echo "you have selected too many industries";
	exit;
}
?>
<?php
//Redirect to results page if user stayed in 5 option
//range
if ($_SERVER["REQUEST_METHOD"] == "POST") {
 Header("Location:
http://www.......com/TAresults.php";);
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<?php //PHP ADODB document - made with PHAkt 2.7.3?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<table width="500" border="1" align="center"
cellpadding="2" cellspacing="2">
  <tr>
    <td><form name="form1" id="form1" method="post"
action="">
      <select name="industry[]" size="10"
multiple="multiple" id="industry[]">
        <option value="1" <?php if (!(strcmp(1,
"Please Select"))) {echo "SELECTED";}
?>>Accounting</option>
        <option value="2" <?php if (!(strcmp(2,
"Please Select"))) {echo "SELECTED";}
?>>Entertainment</option>
        <option value="3" <?php if (!(strcmp(3,
"Please Select"))) {echo "SELECTED";}
?>>label</option>
        <option value="4" <?php if (!(strcmp(4,
"Please Select"))) {echo "SELECTED";} ?>>Advertising
</option>
        <option value="5" <?php if (!(strcmp(5,
"Please Select"))) {echo "SELECTED";} ?>>Customer
Service</option>
        <option value="6" <?php if (!(strcmp(6,
"Please Select"))) {echo "SELECTED";} ?>>Informatin
Technology</option>
      </select>
      <input type="submit" name="Submit"
value="Submit">
    </form></td>
  </tr>
</table>
</body>
</html>

TAresults (page2):

<?php session_start();

if ( empty( $_SESSION['l_industry'] ) ) {
$_SESSION['l_industry']=array();
}

if ( is_array( $_REQUEST['LurkerIndustry'] ) ) {
$_SESSION['l_industry'] = array_unique(
array_merge( $_SESSION['l_industry'],
 $_REQUEST['LurkerIndustry'] )
);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
echo "The time is"."<br />";
echo $industry['0']."<br />"; 
echo $industry['1']."<br />"; 
echo $industry['2']."<br />"; 
echo $industry['3']."<br />"; 
echo $industry['4']."<br />"; 
echo $industry['5']."<br />"; 
echo $industry['6']."<br />"; 
echo $industry['7']."<br />"; 
echo $industry['8']."<br />"; 
echo $industry['9']."<br />"; 
echo $industry['10']."<br />"; 
echo $industry['11']."<br />";

?>
<?php
unset($l_industry);
?>
</body>
</html>

The results here, are whether the check passes or not
the variables never echo. 
If I set action on page 1 to TAresults.php , then they
echo out fine.

Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux