Jump to content

confirm before submit


wwfc_barmy_army

Recommended Posts

Hello. I have this code:
[code=php:0]<?php

include 'dbconnect.php';

$broken = "Y";
$id = $_GET['id'];

$update = mysql_query("UPDATE t_50 SET broken = '$broken' WHERE id = '$id'") or die(mysql_error());

?>
Thanks, we will have a look at it :) [/code]

This code just basically adds something to the 'reported' list. But it happens as soon as the page is loaded. I want something on it so that it can say "Are you sure you want to report?", Then there is a yes and no button. The yes button submits it and the no button cancels it and says "Nothing has been reported".  I''m not sure how to do this though. Can anyone offer any advice/code?

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/27581-confirm-before-submit/
Share on other sites

I am assuming that this comes from another form.

Try something like this

[code=php:0]
<?
if ($run_update == "yes") {
$broken = "Y";
$id = $_GET['id'];

$update = mysql_query("UPDATE t_50 SET broken = '$broken' WHERE id = '$id'") or die(mysql_error());
}


$display_= "<table border-'1' align='center'>
<tr><form method='get' action='$_SERVER[PHP_SELF]'>
<input type='hidden' name='run_update' value='yes'>
<td>Are you sure you want to run update?</td>
<td><input type='submit' name='submit' value='Yes'></td>
</form></tr>
</table>";



?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27581-confirm-before-submit/#findComment-126136
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.