I have a form that I am submitting to itself about halfway through in order to check key fields for information. I know this is simple, and I am sure I have seen it on this discussion but I can't seem to get it figured out.
I have a variable $ckSubmit that I am using to see if my form has been submitted. If the form has been submitted $ckSubmit is incremented by 1.
My code looks something like this...
if ($ckSubmit==2) {
if ($jobdesc=='') echo '<script type = "text/javascript"> alert("Please enter a Project Name");</script>';
if ($client=='A') echo '<script type = "text/javascript"> alert("Please enter a Client Name");</script>';
I know there is an easier way to do this but just need some help.
I don't know why you have to increment the submit may be there is a reason for that? i take it that ckSubmit is the name of the submit button?.
i hope this solves your problem!
Try this! put it in top of the form u use.
PHP Code:
if ($_POST[ckSubmit])
{
if (!$_POST[jobdesc])
{
echo '<script type = "text/javascript"> alert("Please enter a Project Name");</script>';
$error=1;
}
if ($_POST[client]=='A')
{
echo '<script type = "text/javascript"> alert("Please enter a Client Name");</script>';
$error=1;
}
if (!$error)
{
// form is valid do something
exit;
}
}