Expand|Select|Wrap|Line Numbers
- <?php
- session_start();
- require_once ('dbconnect.php'); ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <META http-equiv=Pragma content=no-cache>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Vehicle Master</title>
- <link rel="stylesheet" type="text/css" href="vehicleMaster.css">
- </head>
- <!--<body style="background:url(images/bg.jpg)" >-->
- <body>
- <?php
- $username = "";
- $password = "";
- $errorMessage = "";
- $_SESSION['UserName_Ses'] = "";
- $_SESSION['UserType_Ses'] = "";
- $_SESSION['login'] = "";
- if(isset($_POST['login'])){
- $username=$_POST['userusername'];
- $password=$_POST['userpassword'];
- if((!$username)||(!$password)){
- $login_error = '<p class= "errormsg">Please enter all fields</p>';
- }
- $password_encrpt = md5(substr($password, 1, -1));
- $sql = "SELECT * FROM user WHERE userName='$username' AND userPassword ='$password_encrpt'";
- $result=mysql_query($sql)or die(mysql_error());
- //----------this is use to retriew values---------------------------------------------------------------
- $row = mysql_fetch_array($result) or die(mysql_error());
- //-----------if login success then get user typr to session and go to the login page--------------------
- if(mysql_num_rows($result) == 1){
- $_SESSION['UserType_Ses'] =$row['userType'];
- $_SESSION['UserNamee_Ses'] =$row['userName'];
- $_SESSION['login'] = "";
- $_SESSION['login'] = "True";
- header('Location: main.php');
- }
- else {
- $errorMessage = '<p class="errMsg" align="Center">Invalid Username or Password</p>';
- echo "error";
- }
- }
- ?>
- <table width="566" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="mainTblBorder">
- <!-------------------hedder table-------------------------------------------------->
- <tr>
- <td><?php require_once 'hedder.php'; ?>
- </td>
- </tr>
- <!--------------menu-------------------------------------------------------------->
- <tr>
- <td><?php require_once 'menue.php'; ?>
- </td>
- </tr>
- <!--------------body-------------------------------------------------------------->
- <td>
- <table width="520" id="maintable">
- <tr>
- <td width="234">
- <?php if ($_SESSION['login'] != 'True') {
- echo "login not true";
- login();
- }?>
- <?php if ($_SESSION['login'] == 'True') {
- echo "true";
- login();
- }?>
- </td><td> </td>
- <td><table width="339" border="0" cellpadding="0" cellspacing="0" class="subTableBorder" id="stocksearch">
- <tr>
- <td colspan="2" align="center"><img src="images/subBannerStockSearch.jpg" /></td>
- </tr>
- <tr><?php if(isset($errorMessage)){ echo "$errorMessage"; }?></tr>
- <tr>
- <td width="41%" >Make :</td>
- <td width="59%"><select name="select" style="width:100px">
- <option></option>
- <option></option>
- <option></option>
- </select> </td>
- </tr>
- <tr>
- <td>Model :</td>
- <td><select name="select" style="width:100px">
- <option></option>
- <option></option>
- <option></option>
- </select></td>
- </tr>
- <tr>
- <td>Year :</td>
- <td><select name="select" style="width:100px">
- <option>1</option>
- <option>2</option>
- <option>3</option>
- </select></td>
- </tr>
- <tr>
- <td>Fuel :</td>
- <td><select name="select" style="width:100px">
- <option></option>
- <option></option>
- <option></option>
- </select></td>
- </tr>
- <tr><td colspan="2" align="right"><img src="images/deleteBtn.jpg" /></td></tr>
- </table></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><?php require_once 'footer.php'; ?>
- </td>
- </tr>
- </table>
- <?php
- function login(){
- ?> <form action="index.php" method="post">
- <table width="98%" height="134" border="0" cellpadding="0" cellspacing="0" class="subTableBorder" id="customerLogin">
- <tr valign="top">
- <td colspan="2" width="100%"><img src="images/subBannerCustomerLogin.jpg" /></td>
- </tr>
- <tr valign="top">
- <td>Login ID :</td>
- <td><input name="userusername" type="text" id="userid" /></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input name="userpassword" type="text" id="userpassword" /></td>
- </tr>
- <tr>
- <td height="53" colspan="2" align="right" ><br />
- <input type="submit" name="login" value="Submit" class="btn" height="30" width="50"/><img src="images/tesBtn.jpg" /> </td>
- </tr>
- </table>
- </form>
- <?php }
- ?>
- <!-------------------------end stock search---------------------------------------- -->
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- $_SESSION['UserName_Ses'] = "";
- $_SESSION['UserType_Ses'] = "";
- $_SESSION['login'] = "";
But when I use this , after the login if user wants to go to index page egain it display as not login. because top of the page I set the default value. But user should have the permission to go to the index page without auto sign out. Please help me..