Keeping data entered by user in textbox even after clicking submit button
Usually the program enters the month number, for example: 12, then if you press the "Submit" button, it will indicate the name of the month, in this case December.
The problem is that every time I click the "Submit value in textbox" button, I want the textbox to still contain "12" even after I clicked the submit button.
Ps: Ignore non-English words.
<form method = "post">
4. Insert month(1-12) :
<input type="text" name="monthTxt" value=""><br/>
<input type="submit" value="Submit">
</form>
<?php
$monthTemp = $_POST["monthTxt"];
$testing = $monthTemp;
function bulan($bulan)
{
$months = array(1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni', 7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'December');
if($bulan < 1 || $bulan > 12)
{
echo "Input tidak boleh kurang dari 0, lebih dari 12, atau huruf";
}
else
{
echo $months[$bulan];
}
}
bulan($monthTemp);
?>
+3
source to share
1 answer