Click to See Complete Forum and Search --> : getting post variables...


chadypu
11-23-2003, 10:19 PM
ill only post a small part of the code to be kind :p
$output = $output.'<TR><TD align="center">'.$data[clan].'</TD><TD align="center"><input type="checkbox" name="'.$data[ID].'edit" value="1"> Mark as Read</TD><TD align="center"><input type="checkbox" name="'.$data[ID].'delete" value="1"> Delete</TD></TR>';
}
}
$output = $output.'<TR class="MainMenuRow"><TD align="center" colspan="3"><INPUT TYPE="submit" name="submit2" value=" Delete/Update "><input type="hidden" name="manage" value="1"></TD></TR>
<TR><TD colspan="3">_</TD></TR></TABLE>';
}
else
{
$output = '<BR>You do not have access to this page<BR>';
}

//=======================
}//End manage
//=======================
$manage = $_POST['manage'];
if ($manage)
{
$sql = "SELECT ID FROM challenge ORDER BY ID DESC";
$exe = mysql_query($sql);
$counter = 0;
while($data = mysql_fetch_array($exe))
{
$counter++;
$m = $data[id].'edit';
$d = $data[id].'delete';
$ed = $_POST[$m];
$de = $_POST[$d];
$output = $ed.'<BR>'.$de;

basically what im doing is generating a table with checkboxes for deleting and updating a field, i generated the table with a while variable from grabbing stuff out of the db.

i basically wanna have it grab if the post variable is true in the manage section but i cant really do it dynamically.

How can i go about grabbing all the post variables...

$ed = $_POST[$m];
$de = $_POST[$d];

i know that code doesnt work, i have tried it but is there any other way i can go about this...

sorry if i am not making sense... just ask and ill clarify
EDIT-
link to page (http://www.chadypu.com/teamboards/challenge.php?action=manage)

i removed the restriction so you guys could view the script in action...

pyro
11-24-2003, 08:23 AM
You can access the entire $_POST array, using $_POST. This, for instace, will output the array:

<?PHP
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>

chadypu
11-24-2003, 02:55 PM
that is agood thing to know :)

i used this...

define("m", $data[ID]."edit");
define("d", $data[ID]."edit");
$ed = $_POST[m];
$de = $_POST[d];

i just relized that doesnt work

DaiWelsh
11-25-2003, 05:31 AM
If I understand you correctly, then repeat the query on the handling page and check for the items that you know could be there, e.g. like you already did but

while($data = mysql_fetch_array($exe))
{
$counter++;
if(isset($_POST[$data[id].'edit'))
{ echo('edit record '.$data[id].'<br>'); }
if(isset($_POST[$data[id].'delete'))
{ echo('delete record '.$data[id].'<br>'); }
}