Hi..
This is my loginhome.php code

i done with form fields validation..but im not getting the output..

please help me...

<?php
   //Include database connection details
   require_once('config.php');
   if(isset($_POST['emp_role']) && !empty($_POST['emp_role'])){
   $emp_role=$_POST['emp_role'];
   
   //Array to store validation errors
   $errmsg_arr = array();
   
   //Validation error flag
   $errflag = false;
   
  
   //Function to sanitize values received from the form. Prevents SQL injection
   function clean($str) {
      $str = @trim($str);
      if(get_magic_quotes_gpc()) {
         $str = stripslashes($str);
      }
      return mysql_real_escape_string($str);
   }
   
   //Sanitize the POST values
   
 // username and password sent from form
$T_UserName=$_POST['T_UserName'];
$T_Password=$_POST['T_Password'];
// To protect MySQL injection
$T_UserName = stripslashes($T_UserName);
$T_Password = stripslashes($T_Password);
$T_UserName= mysql_real_escape_string($T_UserName);
$T_Password = mysql_real_escape_string($T_Password);
   //Input Validations
     if($T_UserName == '') {
      $errmsg_arr[] = 'Username missing';
      $errflag = true;
   }
   if($T_Password == '') {
      $errmsg_arr[] = 'Password missing';
      $errflag = true;
   }
      if(strlen($T_UserName) > 30) {
      $errmsg_arr[] = 'Username exceeds allowed charachter limit';
      $errflag = true;
   }
   if(strlen($T_Password) > 30) {
      $errmsg_arr[] = 'Password exceeds allowed charachter limit';
      $errflag = true;
   }
   
      
   
      
      
   
   //If there are input validations, redirect back to the registration form
   if($errflag) {
      $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
      session_write_close();
      header("location:registrationform.php");
      exit();
   }

   //Create INSERT query
$qry="SELECT * FROM `logindetails` WHERE `username`='$T_UserName' AND `password`='$T_Password'";
   $result = @mysql_query($qry);
   
   // Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $T_UserName and $T_Password, table row must be 1 row
if($count==1)
{
$rowrole = mysql_fetch_assoc($result);
$emp_role = $rowrole['emp_role'];
if($emp_role == 1)
{
header("location:adminindex.php");
}
elseif($emp_role == 2 )
{
header("location:managerindex.php");
}
elseif($emp_role == 3)
{
header("location:memberindex.php");
}
}
else
{
echo "Wrong Username or Password";
}
   }
?>

this is my form

<?php
session_start();
include("login.php")
?>
 <form id="form1" name="form1" method="POST" action="login.php">

          <p>
            <label for="T_UserName">User Name</label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="T_UserName" type="text"  id="T_UserName" size="30" maxlength="30" />
          </p>
          <p>
            <label for="T_Password">Password</label>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

              <input name="T_Password" type="password" id="T_Password" size="30" maxlength="30" />
            
          </p>
          <p>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="submit" name="Btn_Submit" id="Btn_Submit" value="Submit" />
            &nbsp;</label>
            &nbsp;
            &nbsp;

        </p>
        <p align="center" ><a href="registrationform.php">New User Register Here</a>
                </form>

Your forms action is set to Login.php, which is the form page. All and all this looks really mixed up. Set the action to loginhome.php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.