I'm new with PHP and still learning.
<?php
if(isset($_POST['btnLogin'])){
$myVariable = $_POST['fieldParameter'];
if(condition){
//do something
}else{
echo "
<form method='POST' action='submit.php'><br/>
<input type='hidden' name='myVariable' value='<?php echo $myVariable; ?>'/>
<br/>
<input type='submit' name='btnSubmit' id='submit' value='Submit'>
</form>
";
}
}
?>
Notice that the variable $myVariable
is contained in the main IF
block. I'm trying to send the value of $myVariable
to submit.php as hidden field.
Also, i enclosed all the html tags using one echo
statement with double quotes.
I found related questions here in SO
but can't find similar to embedding php
within a long echo
of html
tags
I tried to put value='<?php echo $studentNo; ?>'
with no success.
I want to access it in a submit.php file like this,
submit.php
<?php
$aVariable = $_POST['myVariable'];
echo $aVariable;
?>
How can I pass the value contained in $myVariable
as hidden field? Is there something wrong with the way I use double and single quotes?
Thank you.