Posted by Starbuck on 05/05/06 02:36
"J.O. Aho" wrote
> Check that the value is empty and the page has been submitted
>
> if(!empty($submit) && empty($something)) {
> echo "<font color=\"red\">Something: </font>";
> } else {
> echo "Something: ";
> }
>
> To set the value back, you need to make
>
> <input type="text" name="something" value="<?PHP echo $something; ?>">
>
>
> //Aho
Thanks for your suggestion. I just wanted to know, if on my form I have a
Submit and Reset button, how would you reset the value of the Submit button
to denote that the user has hit reset? I've tried a few things and they
haven't worked. Id appreciate any feedback.
Thanks in advance.
<?php
// check to verify that the form has been submitted
if (empty($_POST['Reset']))
{
($_POST['Submit']) = null;
$enterfirstname = false;
$enterlastname = false;
}
else
{
if (empty($_POST['Submit']))
{
//Do nothing. Flag all the required fields to false to denote nothing
has been entered.
$enterfirstname = false;
$enterlastname = false;
}
else
{
// Validate mandatory fields
if (strlen($_POST['firstname']) >= 1)
{
$enterfirstname = true;
}
if (strlen($_POST['lastname']) >= 1)
{
$enterlastname = true;
}
header('Location: accountcreated.php');
}
}
?>
Navigation:
[Reply to this message]
|