Variable Not Passed With $_SERVER['PHP_SELF'] 
Author Message
 Variable Not Passed With $_SERVER['PHP_SELF']

I working on a script that allows a user to display a list of athletic clubs
(in a form) based on the state they're in and then using checkboxes to
select their club(s) and link it to their personal record in a MySQL
database.  Here's the script:

 if (db_connect())
 {
?>
  <p class="text" align="center">Select a state to view the clubs in that
state.<br>
  <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
  State:<select name="club_state">
  <option selected value="blank">
<?
  $query="select distinct state from club";
  $result = mysql_query($query) or die(mysql_error());
  $num_rows = mysql_num_rows($result);
  for ($i=0;$i < $num_rows; $i++);
  {
   $row = mysql_fetch_array($result);

   echo("<option value=\"$row[state]\">$row[state]\n");
  }
?>
  </select></p>
  <center>
  <input type="submit" name="select_clubs" value="Select Clubs">
  </center>
  </form>
<?
  //display clubs in chosen state

  if ($club_state != "blank")
  {

   echo("\$select_clubs = $select_clubs<br>");
   echo("\$club_state = $club_state");

   $query2 = "select club_code,name,address,city,state from club where
state='$club_state'";
   $result2 = mysql_query($query2) or die(mysql_error());
   $num_rows2 = mysql_num_rows($result2);

   if ($select_clubs != "blank")
   {
?>
    <form name="add_clubs" method="post" action="link_clubs_script.php">
    <center>
    <p class="text" align="center">
    <table border="1">
    <tr>
    <th>Select</th>
    <th>Name</th>
    <th>Address</th>
    <th>City</th>
    <th>State</th></tr>
<?
    for ($i=0;$i<$num_rows2;$i++)
    {
     $row2 = mysql_fetch_array($result2);
?>
     <tr>
     <td align="center"><input type="checkbox" name="club_code" value="<?php
echo $row2[club_code]?>"</td>
     <td><?php echo $row2['name']?></td>
     <td><?php echo $row2['address']?></td>
     <td><?php echo $row2['city']?></td>
     <td><?php echo $row2['state']?></td>
     </tr>
<?
    }
?>
    </table>
    </p>
    <input type="submit" name="add_clubs" value="Add Clubs">
    </form>
    </center>
<?
   }
   else
   {
    echo("<p class=\"text\" align=\"center\">No clubs returned from
query.</p><br>");
   }
  }
 }

?>

The problem I'm having is that the $club_state and $select_clubs variables
are not being passed for some reason, so they are not available to be used
as criteria in the script.  I've used this identical methjod in other
scripts without a problem, but I can't tell why it's not getting passed
here.  Can anyone tell me why these variables aren't getting passed?

Thanks.

Steve



Tue, 14 Jun 2005 08:18:53 GMT  
 Variable Not Passed With $_SERVER['PHP_SELF']

Quote:

>   <form method="post" action="<?=$_SERVER['PHP_SELF']?>">

Aha, $_SERVER['PHP_SELF'] rather than just $PHP_SELF. Good, but I wonder if
you realized why?

Quote:
>   State:<select name="club_state">
..
>   if ($club_state != "blank")

Hmm, $club_state instead of $_POST['club_state'] here.

Quote:
> I've used this identical methjod in other scripts without a problem

But not on the same server, did you? See http://php.net/tutorial.oldcode

Palahala



Tue, 14 Jun 2005 16:00:35 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Tcl-dp problem, 'Server not responding'

2. $_GET variable variables, dynamic parsing (I'm not sure how to summarize this question)

3. un-'upvar'ing/un-'global'ing variables

4. openMP: threadprivate not effected and function variables not passed

5. Page not working on new server, can't understand code

6. KeyEvent's CtrlKeyMask class variable is not initialized

7. Non-Procedure routine's variables not global ?

8. 'One-pass' Compilation Issues

9. Ada to 'C' parameter passing problem

10. pre-PEP for optional 'pass'

11. Info passed thru 'Event'

12. Info passed thru 'Event'

 

 
Powered by phpBB® Forum Software