Q:

Posting value through form hidden field in PHP

I have the following code:
<?php
$student_no = $_GET['student_no'];
echo '<form  name="student" action="PROCESS_FEE007.php" method="POST">';
echo '</br><table>';
echo '**<input name="student_no" type="hidden" value="$student_no"  />**';
echo '<td>Amount: </td><td>'.'<input name="amount" type="text" /></td></tr>'; 
echo '<tr> <td>Remarks: </td><td>'.'<input name="remarks" type="text"  /> </td>';
echo '<tr> <td>';
echo '<td>'.'<input type="submit" value="Save"/></td></tr>';
echo '</table>';
echo '</form>';
?>

On the next page PROCESS_FEE007.PHP the value is not received.

A:

Variables are not parsed by interpreter inside single quotes. You should use double quotes or explicit string concatenation.
In your example the value of $_POST['student_no'] will be string '$student_no', not the value of the $student_no variable.
Besides if you're using method="POST" in your form, you can only get the inputs value through the $_POST array.
<?php
$student_no = $_POST['student_no'];
echo '<form  name="student" action="PROCESS_FEE007.php" method="POST">';
echo '</br><table>';
echo '**<input name="student_no" type="hidden" value="'.$student_no.'"  />**';
echo '<td>Amount: </td><td>'.'<input name="amount" type="text" /></td></tr>'; 
echo '<tr> <td>Remarks: </td><td>'.'<input name="remarks" type="text"  /> </td>';
echo '<tr> <td>';
echo '<td>'.'<input type="submit" value="Save"/></td></tr>';
echo '</table>';
echo '</form>';
?>

A:

try using $_REQUEST instead of get example $student_no = $_REQUEST['student_no']; 

