I'm pretty new to PHP and MySQL. I have managed to create a form that inserts data to MySQL and to create a form to search the DB. Now here is my problem. I am unsuccessful coding a hidden variable in an update page. Here is what I have:
search_ir.php (this page searches the DB and lists incident_id's found. User then enters the incident_id of the row to update):
[code=html]
....
<FORM METHOD="POST" ACTION="edit_ir .php">
<h3>Enter the Incident ID for the Report You Need to Edit:</h3>
<table border="0" cellpadding="0" >
<tr>
<td><INPUT TYPE=TEXT NAME="incident_ id" VALUE="" SIZE=6 MAXLENGTH=6></td>
<td><INPUT TYPE=SUBMIT VALUE="Edit"></td>
<td><INPUT TYPE=RESET VALUE="Reset"></td>
</tr>
</table>
</FORM>
....
[/code]
edit_ir.php (this page receives the incident_id entered above and displays the data - some of the data has been completed, but other fields are inputted on this page to then update the row in the db on submit):
[code=php]
...
<?php
$db = mysql_connect(" localhost", "root", "no2nt"); mysql_select_db ("etest",$db );
$result = mysql_query("SE LECT * FROM jos_incidents_c ombined WHERE incident_id = '$_REQUEST[incident_id]'",$db);
while ($myrow = mysql_fetch_arr ay($result))
{
echo $myrow["incident_i d"];
...
<FORM NAME = "rm_edit_ir " METHOD="POST" ACTION="ir_upda ted.php">
...
<INPUT TYPE=HIDDEN NAME="incident_ id" VALUE="<?php echo $_REQUEST[incident_id]; ?>">
<INPUT TYPE=SUBMIT VALUE="Submit Form" >
<INPUT TYPE=RESET VALUE="Reset Form">
</FORM>
...
[/code]
ir_updated.php (updates the db with the data from above code):
[code=php]
...
$sql = "UPDATE jos_incidents_c ombined SET
assess_ortho = '$_REQUEST[assess_ortho]',
rescore_morse = '$_REQUEST[rescore_morse]'
WHERE incident_id = '$_REQUEST[incident_id]'";
...
[/code]
In ir_updated.php, I get the error:
"Notice: Use of undefined constant incident_id - assumed \'incident_id\' in /usr/local/php_classes/edit_ir.php on line 238"
line 238 in edit_ir.php is this:
[code=html]
<INPUT TYPE=HIDDEN NAME="incident_ id" VALUE="<?php echo $_REQUEST[incident_id]; ?>">
[/code]
Should I be passing something else instead of ="<?php echo $_REQUEST[incident_id]; ?>, or am I not referring to the variable properly?
TIA,
jej1216
search_ir.php (this page searches the DB and lists incident_id's found. User then enters the incident_id of the row to update):
[code=html]
....
<FORM METHOD="POST" ACTION="edit_ir .php">
<h3>Enter the Incident ID for the Report You Need to Edit:</h3>
<table border="0" cellpadding="0" >
<tr>
<td><INPUT TYPE=TEXT NAME="incident_ id" VALUE="" SIZE=6 MAXLENGTH=6></td>
<td><INPUT TYPE=SUBMIT VALUE="Edit"></td>
<td><INPUT TYPE=RESET VALUE="Reset"></td>
</tr>
</table>
</FORM>
....
[/code]
edit_ir.php (this page receives the incident_id entered above and displays the data - some of the data has been completed, but other fields are inputted on this page to then update the row in the db on submit):
[code=php]
...
<?php
$db = mysql_connect(" localhost", "root", "no2nt"); mysql_select_db ("etest",$db );
$result = mysql_query("SE LECT * FROM jos_incidents_c ombined WHERE incident_id = '$_REQUEST[incident_id]'",$db);
while ($myrow = mysql_fetch_arr ay($result))
{
echo $myrow["incident_i d"];
...
<FORM NAME = "rm_edit_ir " METHOD="POST" ACTION="ir_upda ted.php">
...
<INPUT TYPE=HIDDEN NAME="incident_ id" VALUE="<?php echo $_REQUEST[incident_id]; ?>">
<INPUT TYPE=SUBMIT VALUE="Submit Form" >
<INPUT TYPE=RESET VALUE="Reset Form">
</FORM>
...
[/code]
ir_updated.php (updates the db with the data from above code):
[code=php]
...
$sql = "UPDATE jos_incidents_c ombined SET
assess_ortho = '$_REQUEST[assess_ortho]',
rescore_morse = '$_REQUEST[rescore_morse]'
WHERE incident_id = '$_REQUEST[incident_id]'";
...
[/code]
In ir_updated.php, I get the error:
"Notice: Use of undefined constant incident_id - assumed \'incident_id\' in /usr/local/php_classes/edit_ir.php on line 238"
line 238 in edit_ir.php is this:
[code=html]
<INPUT TYPE=HIDDEN NAME="incident_ id" VALUE="<?php echo $_REQUEST[incident_id]; ?>">
[/code]
Should I be passing something else instead of ="<?php echo $_REQUEST[incident_id]; ?>, or am I not referring to the variable properly?
TIA,
jej1216
Comment