You are here: Re: VALIDATING MANDATORY FIELDS USING PHP NOT JAVA SCRIPT!?! « All PHP « IT news, forums, messages
Re: VALIDATING MANDATORY FIELDS USING PHP NOT JAVA SCRIPT!?!

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация