Page 1 of 1

[SOLVED] Disappearing Variable

Posted: Sun Jun 20, 2004 10:18 pm
by mattmcb
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

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 ('
&nbsp;<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>&nbsp;
');}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();
}
feyd|for future reference, please use

Code: Select all

tags when posting php code.[/color]

Posted: Sun Jun 20, 2004 10:37 pm
by mattmcb
Nevermind... I'm an idiot. I wasn't saving the variable each time... I was just printing it out and not capturing it again.

Posted: Sun Jun 20, 2004 11:11 pm
by feyd
that was easy to solve :P

Posted: Sun Jun 20, 2004 11:25 pm
by John Cartwright
your elite feyd