|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-06-07 23:29 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 01:00:01 2025 UTC |
The problem: PHP doesn't seem to kill my variable ($allow) correctly. I dunno if i'm just to tired, it's 30 min past midnight, so bare with me. I just found out and consulted another reliable guy, he just told me to get used to it.. I thought it would be good if you guys knew. My Setup: Normal Win32 setup, no changes to standart php.ini, running apache 1.3.24. database content: mysql> select * from permission_table +----+------------+---------+-------+ | id | actiontype | groupid | allow | +----+------------+---------+-------+ | 1 | changenews | 0 | 0 | | 2 | changenews | 5 | 1 | | 6 | changenews | 4 | 0 | +----+------------+---------+-------+ ------ SCRIPT START ------ <? include("root.php"); include("$root/dbopen.php"); mysql_select_db("spacenet"); $res = mysql_query("SELECT * FROM permission_table") or die(mysql_error()); ?> <script language="JavaScript"> <!-- function setvars(allow,id) { document.perm_form.allow.value=allow; document.perm_form.id.value=id; } //--> </script> <form name="perm_form" action="./func_change_permission.php" method="post"> <table border="1" summary="permissions"> <tr> <td>id</td> <td>groupid</td> <td>actiontype</td> <td>allow</td> <td colspan="2"> </td> </tr> <? while($row = mysql_fetch_array($res)) { echo "<tr>\n"; echo "\t<td>$row[0]</td>\n"; echo "\t<td>".$row["groupid"]."</td>\n"; echo "\t<td>$row[1]</td>\n"; if($row["allow"]=="1") $allow = "checked"; else // this else is essential, without it, PHP forgets to reset (kill) $allow, so $allow is always = "checked" $allow = ""; echo "\t<td><input type=\"checkbox\" value=\"1\" name=\"val_$row[id]\" $allow >".$row["allow"]."</td>\n"; echo "\t<td><a href=\"func_remove_permission.php?id=$row[0]\">[fjern]</a></td>\n"; echo "\t<td><a href=\"#\" onclick=\"setvars(document.perm_form.val_$row[id].checked,$row[id]);document.perm_form.submit()\">[Gem]</a></td>\n"; echo "</tr>\n"; } ?> </table> <input type="hidden" value="<?=mysql_num_rows($res)?>" name="num_rows"> <input type="hidden" value="" name="allow"> <input type="hidden" value="" name="id"> <input type="submit" value="Gem" title="Gem ?ndringer"> </form> <form action="./func_add_permission.php" method="post"> <b>Add permissions:</b> <table border="0"> <tr> <td>Actiontype: </td><td><input type="text" name="actiontype" value=""></td> </tr> <tr> <td>Allow: </td><td><input type="checkbox" name="allow" value="1" ></td> </tr> <tr> <td>Group ID: </td><td><input type="text" name="groupid" value="" ></td> </tr> </table> <input type="submit" value="Gem" > </form> <? include("$root/dbclose.php"); ?> ------ END OF SCRIPT -------