balasundaram
asked on
PHP and html
I have one problem. I am having two pages. In first page if I leave some mantitoy fields empty and if I click submit. The same first page must be displayed with changing the color(to red) of the names of the manditory fields that are not filled but all other data in other fields must be there. I don't know how to do it. Since I am new to php and using PHP3. Please help me.
ASKER
hello sir,
your code works perfectly. but if I refresh the previous values are maintained. How I can overcome this problem?
your code works perfectly. but if I refresh the previous values are maintained. How I can overcome this problem?
Sure, when you refresh, you post again your data.
What do you need to do ?
What do you need to do ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<?
function TestField($f)
{
if ($f == "")
print "<font color='#FF0000'>";
}
$field_list = array("Name", "Firstname");
if ($REQUEST_METHOD == "POST")
{ for($i=0; $i<count($field_list);$i++
{ if ($$field_list[$i] == "")
$err=true;
}
if ($err<>true)
header("Location: confirm.php3");
}
?>
<form action="form.php3" method="post">
<?TestField($Name)?>Name</
<input type="text" value="<?print $Name?>" name="Name"><br>
<?TestField($Firstname)?>F
<input type="text" value="<?print $Firstname?>" name="Firstname"><br>
<input type="submit" value="submit" name="submit">
</form>