Forum Moderators: coopster

Message Too Old, No Replies

HTML form not going where i want it to

         

Esqulax

4:07 pm on Nov 24, 2007 (gmt 0)

10+ Year Member



Ok.. posting again straight after the 1st one, with a different issue!

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>

sandy103

4:52 pm on Nov 24, 2007 (gmt 0)

10+ Year Member



Ok. I found out what went wrong in your code and why it is not redirecting to del.php.

Check your code. You are missing '=' sign after the action statement in the form. I think it will redirect if you change it to action="del.php".

Bye

Esqulax

12:37 am on Nov 25, 2007 (gmt 0)

10+ Year Member



Ooer...
I feel really stupid now...

Thanks!
Its surprising what silly things get missed when you stare at code for hours on end!