Posting to same page and different page through form
Posted: Sat Dec 13, 2003 12:03 pm
Hi everyone,
As a part of a website i am making i have a form which you select items using a checkbox and then you can delete them. However i would also like to be able to select these and if the user presses edit it will take them to a different page and still transport what they have selected so then another form will come up so they can edit the item they have selected. But i am not sure on how to do this can one form have several actions, or is there another way to do this. Code at moment is:
If anyone can suggest how i can do this i would be grateful
(Added eyecandy coloring - infolock)
As a part of a website i am making i have a form which you select items using a checkbox and then you can delete them. However i would also like to be able to select these and if the user presses edit it will take them to a different page and still transport what they have selected so then another form will come up so they can edit the item they have selected. But i am not sure on how to do this can one form have several actions, or is there another way to do this. Code at moment is:
Code: Select all
form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<TABLE border = "1" cellspacing="0" cellpadding="3">
<TR><TD colspan="4" bgcolor="#0099FF"><b><CENTER>Tasks</CENTER></b></td>
<TR><TD colspan="4" bgcolor="#c0c0c0"></td>
<!-- <TR><TD align="right" bgcolor="#c0c0c0">User To Delete</td></td><td bgcolor="#c0c0c0"> -->
<tr><td align = "left" width = "1.25%" bgcolor = "#c0c0c0"><b>Select</td><td width = "1.25%" bgcolor = "#c0c0c0"><b>Task ID</td><td width = "80%" bgcolor = "#c0c0c0"><b>Subject</td><td width = "17.5" bgcolor = "#c0c0c0"><b>Due Date</b></td></tr>
<?php
$userid = $_SESSION['user_id'];
$query = "SELECT tasks.task_id, tasks.subject, DATE_FORMAT(tasks.duedate, '%e/%m/%Y') AS dd FROM tasks, taskregister WHERE taskregister.user_id='$userid' AND taskregister.task_id = tasks.task_id";
$result = @mysql_query($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "<TR><TD align="left" bgcolor="#c0c0c0"><input type = "Checkbox" name="TaskDelete[]" value={$row['task_id']}></td><td bgcolor="#c0c0c0">{$row['task_id']}</td><td bgcolor="#c0c0c0">{$row['subject']} </td><td bgcolor="#c0c0c0">{$row['dd']}<br></td></tr>";
}
?>
</TABLE>
<div align=center />
<p>
<input type="image" src="images/delete.png">
<input type="hidden" name="Delete">
</form>
<?php
if (isset($_POST['Delete'])) {
if (isset($_POST['TaskDelete']) && (count($_POST['TaskDelete'] > 0))) {
$a = $_POST['TaskDelete'];
$i = 0;
foreach ($a as $v) {
$query= "DELETE FROM tasks WHERE task_id=$a[$i]";
mysql_query($query) or die (mysql_error());
$i++;
}
}
}
?>(Added eyecandy coloring - infolock)