I've been trying to create a program to put cemetery records into a database.
In creating the Modify Records section, I have three files: pick_modrecords.php, show_modrecords.php and do_modrecords.php
The pick_modrecord.php file brings up a list of records from the appropriate table and allows me to select a record to modify...which goes on to the show_modrecord.php file.
The show_modrecord.php file allows me to enter/change info, but when I hit the Update Record button, it doesn't make the changes in the database and show me a confirmation that the Update has taken place (the do_modrecord.php file). Instead, it goes back to the pick_modrecord.php file for me to begin the process all over again.
Below are the three files minus the database secrets. If anyone can direct me to what needs to be changed where so this script will work, I'd be very grateful.
pick_modrecord.php:
$sql ="SELECT id, LastName, FirstName FROM $table_name ORDER BY LastName";
$result = @mysql_query($sql,$connection) or die(mysql_error());
//check the number of results
$num = @mysql_num_rows($result);
if ($num < 1) {
//if there are no results,display message
$display_block = "<P><em>Sorry!No results.</em></p>";
} else {
//if results are found,loop through them
//and make a form selection block
while ($row = mysql_fetch_array($result)){
$id = $row['id'];
$LastName = $row['LastName'];
$FirstName = $row['FirstName'];
$option_block .="<option value=\"$id\">$LastName,$FirstName</option>";
}
//create the entire form block
$display_block ="
<FORM METHOD=\"POST\" ACTION=\"show_modrecord.php\">
<P><strong>Contact:</strong>
<select name=\"id\">
$option_block
</select>
<INPUT TYPE=\"SUBMIT\" NAME=\"submit \"VALUE=\"Select this Record\"></P>
</form>";
}
?>
<HTML>
<HEAD>
<TITLE>Middlebury Union Cemetery Records Management System:Modify a Record</TITLE>
</HEAD>
<BODY>
<h1>Middlebury Union Cemetery Records Management System</h1>
<h2><em>Modify a Record - Select from List</em></h2>
<P>Select a record from the list below to modify the record.</P>
<? echo "$display_block"; ?>
<br>
<p><a href="admin1.php">Return to Main Menu</a></p>
</BODY>
</HTML>
show_modrecord.php
$sql ="SELECT EndowmentNumber, Letter, LotSize, Section, LotNumber, LotOwner, LastName, FirstName, Born, Died, VeteranInfo, MiscInfo FROM $table_name WHERE id ='$_POST[id]'";
$result =@mysql_query($sql,$connection)or die(mysql_error());
//get results for display
while ($row =mysql_fetch_array($result)){
$EndowmentNumber =$row ['EndowmentNumber'];
$Letter =$row ['Letter'];
$LotSize =$row ['LotSize'];
$Section =$row ['Section'];
$LotNumber =$row ['LotNumber'];
$LotOwner =$row ['LotOwner'];
$LastName =$row ['LastName'];
$FirstName =$row ['FirstName'];
$Born =$row ['Born'];
$Died =$row ['Died'];
$VeteranInfo =$row ['VeteranInfo'];
$MiscInfo =$row ['MiscInfo'];
}
?>
<HTML>
<HEAD>
<TITLE>Middlebury Union Cemetery Records Management System:Modify a Record</TITLE>
</HEAD>
<BODY>
<h1>Middlebury Union Cemetery Records Management System</h1>
<h2><em>Modify a Record</em></h2>
<FORM METHOD="post"ACTION="do_modrecord.php">
<INPUT TYPE="hidden" name="id" value="<? echo "$_POST[id]"; ?>">
<table cellspacing=3 cellpadding=5>
<tr>
<th>LOTS & GRAVES INFORMATION</th>
</tr>
<tr>
<td valign=top>
<P><STRONG>EndowmentNumber:</STRONG><BR>
<INPUT TYPE="text" NAME="EndowmentNumber" VALUE="<? echo "$EndowmentNumber"; ?>" SIZE=5 MAXLENGTH=10></P>
<P><STRONG>Letter:</STRONG><BR>
<INPUT TYPE="text" NAME="Letter" VALUE="<? echo "$Letter"; ?>" SIZE=5 MAXLENGTH=10></P>
<P><STRONG>LotSize:</STRONG><BR>
<INPUT TYPE="text" NAME="LotSize" VALUE="<? echo "$LotSize"; ?>" SIZE=10 MAXLENGTH=10></P>
<P><STRONG>Section:</STRONG><BR>
<INPUT TYPE="text" NAME="Section" VALUE="<? echo "$Section"; ?>" SIZE=2 MAXLENGTH=5></P>
<P><STRONG>LotNumber:</STRONG><BR>
<INPUT TYPE="text" NAME="LotNumber" VALUE="<? echo "$LotNumber"; ?>" SIZE=5 MAXLENGTH=10></P>
<P><STRONG>LotOwner:</STRONG><BR>
<INPUT TYPE="text" NAME="LotOwner" VALUE="<? echo "$LotOwner"; ?>" SIZE=25 MAXLENGTH=50></P>
<P><STRONG>Last Name:</STRONG><BR>
<INPUT TYPE="text" NAME="LastName" VALUE="<? echo "$LastName"; ?>" SIZE=25 MAXLENGTH=50></P>
<P><STRONG>First Name:</STRONG><BR>
<INPUT TYPE="text" NAME="FirstName" VALUE="<? echo "$FirstName"; ?>" SIZE=25 MAXLENGTH=50></P>
<P><STRONG>Born:</STRONG><BR>
<INPUT TYPE="text" NAME="Born" VALUE="<? echo "$Born"; ?>" SIZE=10 MAXLENGTH=10></P>
<P><STRONG>Died:</STRONG><BR>
<INPUT TYPE="text" NAME="Died" VALUE="<? echo "$Died"; ?>" SIZE=10 MAXLENGTH=10></P>
<P><STRONG>VeteranInfo:</STRONG><BR>
<INPUT TYPE="text" NAME="VeteranInfo" VALUE="<? echo "$VeteranInfo"; ?>" SIZE=100 MAXLENGTH=100></P>
<P><STRONG>MiscInfo:</STRONG><BR>
<INPUT TYPE="text" NAME="MiscInfo" VALUE="<? echo "$MiscInfo"; ?>" SIZE=100 MAXLENGTH=200></P>
</td>
</tr>
<tr>
<td align=center colspan=2><br>
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Update Record"></P>
<br>
<p><a href="admin1.php">Return to Main Menu</a></p>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
do_modrecord.php
$sql ="UPDATE $table_name SET
EndowmentNumber ='$_POST[EndowmentNumber]',
Letter ='$_POST[Letter]',
LotSize ='$_POST[LotSize]',
Section ='$_POST[Section]',
LotNumber ='$_POST[LotNumber]',
LotOwner ='$_POST[LotOwner]',
LastName ='$_POST[LastName]',
FirstName ='$_POST[FirstName]',
Born ='$_POST[Born]',
Died ='$_POST[Died]',
VeteranInfo ='$_POST[VeteranInfo]',
MiscInfo ='$_POST[MiscInfo]'
WHERE id ='$_POST[id]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>
<HTML>
<HEAD>
<TITLE>My Contact Management System:Contact Updated</TITLE>
</HEAD>
<BODY>
<h1>Middlebury Union Cemetery Records Management System</h1>
<h2><em>Modify a Record - Record Updated</em></h2>
<P>The following information was successfully updated in <? echo "$table_name"; ?></P>
<table cellspacing=3 cellpadding=5><tr>
<th>LOTS & GRAVES INFORMATION</th>
</tr>
<tr>
<td valign=top>
<P><STRONG>EndowmentNumber:</STRONG><BR>
<? echo "$_POST[EndowmentNumber]"; ?></P>
<P><STRONG>Letter:</STRONG><BR>
<? echo "$_POST[Letter]"; ?></P>
<P><STRONG>LotSize:</STRONG><BR>
<? echo "$_POST[LotSize]"; ?></P>
<P><STRONG>Section:</STRONG><BR>
<? echo "$_POST[Section]"; ?></P>
<P><STRONG>LotNumber:</STRONG><BR>
<? echo "$_POST[LotNumber]"; ?></P>
<P><STRONG>LotOwner:</STRONG><BR>
<? echo "$_POST[LotOwner]"; ?></P>
<P><STRONG>Last Name:</STRONG><BR>
<? echo "$_POST[LastName]"; ?></P>
<P><STRONG>First Name:</STRONG><BR>
<? echo "$_POST[FirstName]"; ?></P>
<P><STRONG>Born:</STRONG><BR>
<? echo "$_POST[Born]"; ?></P>
<P><STRONG>Died:</STRONG><BR>
<? echo "$_POST[Died]"; ?></P>
<P><STRONG>VeteranInfo:</STRONG><BR>
<? echo "$_POST[VeteranInfo]"; ?></P>
<P><STRONG>MiscInfo:</STRONG><BR>
<? echo "$_POST[MiscInfo]"; ?></P>
</td>
</tr>
<tr>
<td align=center colspan=2><br>
<p><a href="admin1.php">Return to Main Menu</a></p>
</TD>
</TR>
</TABLE></BODY>
</HTML>