Hello.
After a user confirms deletions of a db record they are re-directed to the main page again. That page should delete the record they confirmed previously and also show the $message text if in fact a record was deleted. Since a user can also come to this second page before deleting a record, the if statement shouldn't run in this case, or if does the $message variable should default to an empty string and display that.
Here's the If statement I'm running:
if ('$POST[ID]') {
$sql = "DELETE FROM $table_name WHERE ID = '$POST[ID]'";
$message = "<p><font color=\"red\" size=\"2\">-- record deleted --</font></p>";
}
else {
$message = "";
}
In the main body of the HTML I'm running this script:
<? if ($message) { echo $message; }?>
This works great after confirming a delete...I get no error messages and the $message displays in red as it should.
However, if I try to access this page directly (by putting the url into the browser) I get the following error message:
Notice: Undefined index: ID in D:\Inetpub\dist-web\projects\uacp\survey\survey_results.php on line 58
Moreover, the $message still shows up as the red text saying -- record deleted -- even though no record was ever specified or deleted.
Can anyone help me figure out what the problem with my if/else code might be?
Thanks,
S./