Forum Moderators: coopster
Right i have a PHP page that has 2 HTML forms on it, both having submit buttons
the 1st submit, takes the ticked checkbox values, extracts MySQL data, and writes it to an array (guest)id[])
and prints on the same page... (windows style...) "are you sure?"
Sweet.
underneath my happy message, another submit button called YES is placed, this one i want to redirect to another page, while keeping the previous array inatct so's i can run the delete script on another page.
On my next page i have
$delvalue=$_POST['delid']
And the a loop to display the contents.
Ok.. problems are:
On clickng the second submit button (YES), the curent page just refreshes, and it doesnt forward to the page i want it to (del.php)
any help would be awesome!
Colin
<head>
<title>DELETED!</title>
</head>
<?php
//Sandatrd connection scripts
$conn=@mysql_connect("localhost","root","")
or die("error connecting to database");
$rs=@mysql_select_db("hotel", $conn)
or die("Error connecting to Hotel");
$sql = "SELECT * FROM guest_data ORDER BY guest_id, name, surname";
$result = mysql_query($sql,$conn) or die("error using result query");
echo ("<table border= 1>");
echo ('<form method="post" action="'.$self.'">');
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr>\n";
echo "<td>". $row['guest_id'] . '<input name="guestid[]" type="checkbox" value="' . $row['guest_id'] . '"></td>';
echo "<td>" . $row['name'] ;
echo "<td>" . $row['surname'];
}
?>
<tr>
<td>
<input type="submit" name="submit" value="submit"></td>
</form>
</tr>
</table>
<?php
echo('<form method="post" action"del.php">');
$delid = $_POST["guestid"];
$how_many=count($delid);
if ($how_many>0)
{
echo ("You chose the following records:<br>");
for ($i=0; $i<$how_many; $i++)
{
echo (($i+1) . " - " . $delid[$i] . "<br>");
}
echo("Ok to delete ".$how_many." record(s)?");
echo('<input type="submit" name="submit" value="Yes">');
echo('</form>');
}
?>
<body>
</body>
</html>