Page 1 of 1

Indicating missing Fields

Posted: Mon Nov 05, 2007 9:57 am
by phpcoder
Hi,

I got simple form to get user information then on same page I am validating form field using PHP. If user did not enter mandatory filed I want to display the same page indicating the missing files. like "mail address is required".

customer.php


Code: Select all

if(isset($_POST['getValidate']))
	{
		if ($_POST['fname'] == "")
			{
			$error[$cnt] = "Name ";
			$cnt++;
			echo "Name";
			$erFlag = 0;
			}
		if($_POST['lname'] == "")
			{
			$error[$cnt] = "Last Name ";
			$cnt++;
			$erFlag = 0;
			echo "Last  Name";			
			}
		if($_POST['email'] == "")
			{
			$error[$cnt] = "Email address "; 
			$cnt++;
			$erFlag = 0;
						echo "Email";			
			}
		if($_POST['address1'] == "")
			{
			$error[$cnt] = "Address ";
			
			$cnt++;
			$erFlag = 0;
						echo "Add";
			}
		if($_POST['address2'] == "")
			{
			$error[$cnt] =  "Address ";
			
			$cnt++;
			$erFlag = 0;		
						echo "Add2";	
			}
		if($_POST['county'] == "0")
			{
			$error[$cnt] = "County ";
			$cnt++;
			$erFlag = 0;			
						echo "County<br>";
						echo $_POST['county']."<br>";
						
			}
			
		if($_POST['pcode'] == "")
			{
			$error[$cnt] = "Post code ";
			$cnt++;
			$erFlag = 0;			
						echo "Post Code";
			}
		if($_POST['tel'] == "")
			{
			$error[$cnt] = "telephone "; 
			$cnt++;
			
			$erFlag = 0;			
						echo "Tele";
			}
		if($_POST['cel'] == "")
			{
			$error[$cnt] = "Mobile number "; 
			$cnt++;
			$erFlag = 0;			
						echo "Mobile";
			}
			
			echo "Flag is ". $erFlag;
		
		if($erFlag)
			{
				header("location:confirm.php?name=fahad");
  				exit; 
				
				}
				else
				{
				
								
				
				
				
				}
How can I disply user with page indicating missing fileds and the customer page as well.

Thanks
[/quote]

Posted: Mon Nov 05, 2007 10:17 am
by feyd