Hello everyone,
So I have php file that creates a form first with text fields and buttons. Then if you click one of the buttons it goes and retrieves the information from mysql database and the text fields are used as the conditions for retrieving. Next after the information is retrieved, it will be posted in newly created text fields and an option button will be created that gives you the choice to change and update the retrieved information.
The problem is that when you click on the option button it doesn't update but rather goes to another php file that I have.
<?php
/* Program: retrieve.php*/
include("long.inc");
{}
$cxn = mysqli_connect($host, $user,$passwd,$dbname)
or die ("Couldn't connect to server.");
echo "<html><body width='100%' style='margin: 0'>
<form action='retrieve.php' method='POST'>
<table width='100%' height='0%' border='0' cellpadding='0' cellspacing='0'>
<tr><td colspan='3' class='white_banner'> Personal Data Form</td></tr>
<table width='100%' border='0'>
<tr><td class='bold_centre'>Personal Info:</td><td class='bold_centre'>First
Name</td>
<td><input type='text' name='ffirstname13' value='$ffirstname13'
size='20' maxsize='20'></td>
<td class='bold_centre'>Last Name</td>
<td><input type='text' name='flastname13' value='$flastname13'
size='20' maxsize='20'></td></tr>
<tr><td class='bold_centre'>Dependent Info:</td><td
class='bold_centre'>Family Name</td>
<td><input type='text' name='ffname13' value='$ffname13'
size='20' maxsize='20'></td>
<td class='bold_centre'>First Name</td>
<td><input type='text' name='ffirstname14' value='$ffirstname14'
size='20' maxsize='20'></td></tr>
<tr><td class='bold_centre'>Beneficiary Info:</td><td
class='bold_centre'>Family Name</td>
<td><input type='text' name='ffname14' value='$ffname1'
size='20' maxsize='20'></td>
<td style='text-align: center' colspan='2' <br /><input type='submit'
name='findpersonalinfo' value='Find Personal Info'></td>
<td style='text-align: center' colspan='2'><br /><input type='submit'
name='finddependent' value='Find Dependent
Info'></td></tr></table>";
/*####################################################################################################################*/
if($_POST['findpersonalinfo'] == "Find Personal Info")
{
$query="SELECT * FROM personalinfo WHERE firstname= '$_POST[ffirstname13]'
AND lastname='$_POST[flastname13]'";
$result=mysqli_query($cxn,$query)
or die ("Couldn't execute query.".mysqli_error($cxn));
while($row=mysqli_fetch_assoc($result))
{
extract($row);
echo " <form action='retrieve.php' method='POST'>
<table width='100%' border='0'>
<tr><td class='bold_centre'>First Name</td>
<td><input type='text' name='firstname'
value='$row[firstname]' size='20' maxsize='20'></td>";
echo "<td class='bold_centre'>Last Name</td>
<td><input type='text' name='lastname'
value='$row[lastname]' size='20' maxsize='20'></td>";
echo "<td class='bold_centre'>Date of Birth</td>
<td><input type='text' name='BirthDate'
value='$row[birthdate]' size='20' maxsize='20'></td>";
echo "<td class='bold_centre'>Sex</td>
<td><input type='text' name='Sex' value='$row[sex]' size='20'
maxsize='20'></td></tr>";
echo "<td style='text-align: center' colspan='2'><br /><input
type='submit' name='update1' value='Update Personal
Info'></td>";
echo "<td style='text-align: center' colspan='2'><br /><input
type='submit' name='delete1' value='Delete Personal
Info'></td></tr></form>";
if($_POST['update1']== "Update Personal Info")
{
echo "DONE";
}
elseif($_POST['delete1']== "Delete Personal Info")
{
echo "DONE";
}
}
}
elseif($_POST['finddependent']== "Find Dependent Info")
{
$query="SELECT * FROM dependent WHERE familyname= '$_POST[ffname13]'
AND firstname='$_POST[ffirstname14]'";
$result=mysqli_query($cxn,$query)
or die ("Couldn't execute query.".mysqli_error($cxn));
while($row=mysqli_fetch_assoc($result))
{
extract($row);
echo "<form action='retrieve.php' method='POST'>
<table width='100%' border='0'><tr><td
class='bold_centre'>Family Name</td>
<td><input type='text' name='familyname'
value='$row[familyname]' size='20' maxsize='20'></td>";
echo "<td class='bold_centre'>First Name</td>
<td><input type='text' name='firstname' value='$row[firstname]'
size='20' maxsize='20'></td>";
echo "<td class='bold_centre'>Relationship</td>
<td><input type='text' name='relationship'
value='$row[relationship]' size='20' maxsize='20'></td></tr>";
echo "<tr><td class='bold_centre'>Nationality</td>
<td><input type='text' name='nationality' value='$row[nationality]'
size='20' maxsize='20'></td>";
echo "<td style='text-align: center' colspan='2'><br /><input
type='submit' name='update3' value='Update Dependent
Info'></td>";
echo "<td style='text-align: center' colspan='2'><br /><input
type='submit' name='delete3' value='Delete Dependent
Info'></td></tr></form>";
if($_POST['update3']== "Update Dependent Info")
{
echo "DONE";
}
elseif($_POST['delete3']== "Delete Dependent Info")
{
echo "DONE";
}
}
}
echo "</form></body></html>";
?>
So the problem is that when you click on any of the buttons created by the while loops, it goes to another PHP file instead of posting "DONE".
any suggestions on why this happens?