[RESOLVED] $_POST problem
I have a series of webforms, that all look at the following .php script when a button is clicked (i.e. form action is set to post).
The script is firing, so this works correctly, however the results are not as expected...
Here is my code (I've taken out the server, db etc. variables, but they are correct and this part of the code works as expected):
<?php
include_once('functions.php');
if (isset($_POST['bonddescription']))
{
include_once('reduced_view_issues.php');
include_once('select_issue.php');
}
if (isset($_POST["btnedit"]))
{
include_once('reduced_view_issues.php');
include_once('select_issue2.php');
}
if (isset($_POST["btnupdate"]))
{
include_once('reduced_view_issues.php');
include_once('select_issue2.php');
}
if (isset($_POST["btncancel"]))
{
include_once('reduced_view_issues.php');
include_once('select_issue.php');
}
if (isset($_POST["btndelete"]))
{
$delete=max($_POST['issueid']);
$bond_description=max($_POST['bonddescription']);
$db = new mysqli($server_name, $user_name, $password, $database_name);
$query = "call sp_delete_issue(".$delete.")";
$result = $db->query($query);
$db->close();
break;
include_once('reduced_view_issues.php');
echo $bond_description." has been deleted".$delete;
}
?>
1) When I click on a button on the form 'reduced_view_issues.php' ['bonddescription'] is posted and it then brings up 'select_issue.php' beneath it (this form is a detailed version of the row the button was clicked from), this appears to work correctly.
2) When I click on btnedit on the form 'select_issue.php', 'reduced_view_issues.php' remains on screen, 'select_issue.php' is replaced by 'select_issue2.php', therefore this also appears to work correctly.
3) If I click btncancel on the form 'select_issue2.php', 'reduced_view_issues.php' and 'select_issue.php' are shown on screen, therefore this appears to function correctly.
These next 2 are where the behaviour is not as expected:
4) If I click btndelete, the record is deleted, so the correct 'issusid' is being posted and the SQL code functions correctly. However the $bond_description does not show (oddly it did previously when I didn't execute the SQL code in the script) and instead of just 'reduced_view_issues.php' showing as expected, 'select_issue.php' also shows underneath it. I do not know why this is happening?
5) If I click btnupdate (there is no SQL as yet, I wanted to get the php working first), then it shows 'reduced_view_issues.php', 'select_issue.php' and 'select_issue2.php' in that order, the expected behaviour is to show just 'reduced_view_issues.php' and 'select_issue2.php'.
I can't see anything wrong, but obviously there must be something, can anyone help?
I am hoping this is a very simple fix, as it shouldn't be a complex issue!