[SOLVED] Disappearing Variable
Posted: Sun Jun 20, 2004 10:18 pm
I need some help, for some reason only the SELECT form type has a problem when I process the form twice. All the other variables continue to appear no matter how many times I process the form except for the SELECT types. I can process the form once and it stays, but twice and it's gone.
Please check out the code and let me know what you think:
*The variable is month1
feyd|for future reference, please use
Please check out the code and let me know what you think:
*The variable is month1
Code: Select all
if (!isset($_POST['month1'])) $_POST['month1'] = '';
// function to output form and hold previously entered values.
function user_form() {
// now to output the form HTML.
echo ('
<form method="post" action="'.htmlspecialchars($_SERVER['PHP_SELF']).'">');
if (!$_POST['month1']){
echo ('
<select name="month1"><option value="">[Select One]<option value="January">January<option value="February">February<option value="March">March<option value="April">April<option value="May">May<option value="June">June<option value="July">July<option value="August">August<option value="September">September<option value="October">October<option value="November">November<option value="December">December</select>
');}else{
echo htmlspecialchars($month1);
}
');
}
// has the form been submitted?
if (isset($_POST['submit'])) {
// the form has been submitted
// perform data checks.
//POST Contract Variables
$month1 = $_POST['month1'];
//Strip Slashes from Contract Variables
$month1 = stripslashes(month1);
}
//Error checking here
// Show the form again!
user_form();
exit(); // if the error checking has failed, we'll exit the script!
}
}else {
// the form has not been submitted, let's show it
user_form();
}Code: Select all
tags when posting php code.[/color]