Hello to all,
Well got a little problem with making HTML field read-only.
I need the fields to update my database not to read the fields for any data. I have tried just to echo the value for that field from the database, however, the value is not passed to my update script if I do that. It wants to read that data into the input fields and then update based on the field contents. So just echoing the value will not result in a record update, but reading the actual data contained in the entire record and then editing only the field I need will result in an update.
Process:
I use a form called addSrch.htm. To get the username and DOB.
That brings up a script call addoffsrch.php. Which returns any records that match the critiera along with several links to add offense, view offense, edit offense. The edit offense is the script that is causing me grief. This link calls up a script called offup.php
which works fine, however, I do not want the user to be able to edit the PID or OffenseID field. The udpate is keyed off the offenseID field in association with the PID to call up the record.
The offup.php script is coded below:
<?php
if($userid) {
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
include "open_db.inc";
//$query="SELECT FROM offense WHERE PID = \"".$formVars["PID"]."\"";
$query="SELECT ,DATE_FORMAT(dateDet,'%m-%d-%Y') as dateDet,DATE_FORMAT(dateRel,'%m-%d-%Y') as dateRel,DATE_FORMAT(dateOfOff,'%m-%d-%Y') as dateOfOff FROM offense WHERE offenseID = $userid";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$formVars = array();
$formVars["PID"]=$row["PID"];
$formVars["offenseID"]=$row["offenseID"];
$formVars["offense"]=$row["offense"];
$formVars["dateDet"]=$row["dateDet"];
$formVars["timeDet"]=$row["timeDet"];
$formVars["dateRel"]=$row["dateRel"];
$formVars["timeRel"]=$row["timeRel"];
$formVars["locked"]=$row["locked"];
$formVars["sightSnd"]=$row["sightSnd"];
$formVars["officerCode"]=$row["officerCode"];
$formVars["officerName"]=$row["officerName"];
$formVars["caseNo"]=$row["caseNo"];
$formVars["dateOfOff"]=$row["dateOfOff"];
$formVars["comment"]=$row["comment"];
mysql_close($db);
}
?>
<html>
<head>
<title>Juvenile Tracker System</title>
</head>
<body bgcolor="#000000" text="#FF0000">
<form method="post" action="updateoff.php"<p align=" center">
<p align="center"><font color="#FF0000"><b>Juvenile Tracker System</b></font><p align="center"><font color="#FF0000" size="5"><b>Offense
Update Screen</b></font><p align="left">
<p align="center"><? echo " <td><img src='getoffpic.php?userid=$userid'></td>\n";?>
<div align="center">
<table border="1" width="67%">
<tr>
<td width="72%">
<p align="right">PID:</td>
<td width="91%"><input type="text" name="PID"
value="<? echo $formVars["PID"];?>" size="20">
</td>
</tr>
<td width="72%">
<p align="right">Offense ID:</td>
<td width="91%"><input type="text" name="offenseID"
value="<? echo $formVars["offenseID"];?>" size="20">
</td>
</tr>
<td width="72%">
<p align="right">Offense:</td>
<td width="91%"><input type="text" name="offense"
value="<? echo $formVars["offense"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Date Detained:</td>
<td width="91%"><input type="text" name="dateDet"
value="<? echo $formVars["dateDet"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Time Detained:</td>
<td width="91%"><input type="text" name="timeDet"
value="<? echo $formVars["timeDet"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Date Released:</td>
<td width="91%"><input type="text" name="dateRel"
value="<? echo $formVars["dateRel"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Time Released:</td>
<td width="91%"><input type="text" name="timeRel"
value="<? echo $formVars["timeRel"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Locked:</td>
<td width="91%"><input type="text" name="locked"
value="<? echo $formVars["locked"];?>" size="3">
</td>
</tr>
<tr>
<td width="72%" align="right">Sight/Sound Separation:</td>
<td width="91%"><input type="text" name="sightSnd"
value="<? echo $formVars["sightSnd"];?>" size="3">
</td>
</tr>
<tr>
<td width="72%" align="right">SO#:</td>
<td width="91%"><input type="text" name="officerCode"
value="<? echo $formVars["officerCode"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Officer Name:</td>
<td width="91%"><input type="text" name="officerName"
value="<? echo $formVars["officerName"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Case No:</td>
<td width="91%"><input type="text" name="caseNo"
value="<? echo $formVars["caseNo"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Date of Offense:</td>
<td width="91%"><input type="text" name="dateOfOff"
value="<? echo $formVars["dateOfOff"];?>" size="20">
</td>
</tr>
<tr>
<td width="72%" align="right">Other(100 character max.):</td>
<td width="91%"><input type="text" name="comment"
value="<? echo $formVars["comment"];?>" size="33">
</td>
</tr>
</table>
</center>
</div>
<p align="center"><input type="submit" value="Update" name="Submit">
</p>
<p>
</p>
</form>
<p align="center"> </p>
</body>
</html>
Any help is appreciated.
Thanks and have a great one! :-)