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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.