Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

help about login authentication problem..????

authentication login

  • Please log in to reply
1 reply to this topic

#1 hamayun_4u2004

hamayun_4u2004

    CC Lurker

  • New Member
  • Pip
  • 7 posts

Posted 22 July 2010 - 10:20 PM

i hope all will be fine,

so dear's my problem is , i am making a login syatem with authentication page(by requiring authentication page in index)

i create 4pages, 1)index.php 2)authenticate.php 3) login_form.php 4)login_form_act.php

when i visit my index page directly without going to sign in, it redirect me to the login form.. when i entered my username and password, it again rediect me to the login_form .php rather to goto the index.php page......

and if i remove this line(require("authenticate.php")) from my index page, then code working properly, after login it redirect me to the index page, and when i write again that authentication line, it again give me same problem.... i dont know where is the prob... it again again redirect me to the login_form.php
realy i m stuck, that where is problem, i wasted to days but unable to find that problem is where..

here is my code details: take a look.
please help me.....


authenticate.php

<?php
session_start(); // start session

if(!isset($_SESSION['ADMIN_UNAME']) or !isset($_COOKIE['ADMIN_UNAME']))
{
    $_SESSION['LOGIN_MSJ']="Please...!! Log-In First...!!!";
    header("location:admin_login_form.php");
    exit();
}
?>

index.php



<?php 
session_start();
error_reporting(7);
require("authenticate.php");

 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="style/style.css" rel="stylesheet" />
<title>Welcome TO MIND ORGANIZATION RISALPUR</title>
</head>

<body>
<table width="1002" height="auto" border="0" cellpadding="1" cellspacing="0" align="center">
  <!--DWLayoutTable-->
  <tr>
      <td > <?php include("./basic_pages/header.php"); ?> </td>
  </tr>
 
  <tr>
    <td height="27" colspan="2" valign="top" width="1002"><?php include("./basic_pages/today_tip.php");?></td>
  </tr>

 <tr>
    <td height="27" colspan="2" valign="top" class="dailynews" width="1002" ><?php include("./basic_pages/latest_news.php");?></td></td>
  </tr>
  <tr>
<td height="404" colspan="2">
        <table width="1002" height="auto" cellpadding="2" cellspacing="0" border="0">
          <!--DWLayoutTable-->
         <tr>
               <td width="194" height="400" valign="top">  <?php include(".asic_pagesmenu.php"); ?> </td>   
             <td width="666" valign="top" class="middledisplay">        middle     then data will b display </td>   
             <td width="142" valign="top"><?php include(".asic_pagesexec_member_pics.php"); ?></td>   
         </tr>
        </table>    </td>
   
</tr>
     <tr>
    <td height="20" colspan="2" width="1002"> <?php include(".asic_pagesooter.php"); ?> </td>
   </tr>
</table>
</body>
</html>



admin_login_form.php


<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ADMIN LOG-IN FORM</title>
</head>

<body>
<form action="admin_login_form_act.php" method="post" enctype="multipart/form-data" name="adminlogin">
<table align="center" cellpadding="1" cellspacing="1" border="1">

<tr> <!-- this td will show the login error message if error found -->
    <td align="center" colspan="2"> <?php echo $_SESSION['LOGIN_MSJ']; echo $_SESSION['ADMIN_UNAME']; unset($_SESSION['LOGIN_MSJ']); ?> </td>
</tr>

<tr>
    <td align="center" colspan="2"> Admin Log-In Form </td>
</tr>

<tr>
    <td align="top"> User Name/ID </td>
    <td valign="top"><input type="text" name="uname" size="30" />
</tr>


<tr>
    <td align="top"> User Passwrod </td>
    <td valign="top"><input type="password" name="upass" size="30" />
</tr>

<tr>
    <td align="top">  </td>
    <td valign="top"><input type="checkbox" name="rememberme" value="yes" size="30" /> Remeber Me
</tr>

<tr>
    <td align="center"> </td>
    <td valign="top"><input type="submit" name="submit" value=" Log-In " size="30" /> <input type="reset" name="reset" value=" Reset " />
</tr>
</table>
</form>


</body>
</html>


admin_login_act.php

<?php
session_start();
include("../basic_pages/common.php");

############################# get the login form username and password ################
$username=$_POST['uname']; // take the username from admin form
$userpass=$_POST['upass']; // take the usr password from admin form
$remember=$_POST['rememberme']; // check the remember me option from admin form, if tich or not

############################ finish the username & pass geting portion ###################################

#######################username and pass , query cheking with the database ###########################
$user_verify_query=mysql_fetch_array(mysql_query("SELECT member_uid, member_pass
                                FROM
                                mhrd_member
                                WHERE
                                member_uid='$username'
                                AND
                                member_pass='$userpass'",$connection));

if($username=="" or $userpass=="")
    {
      $_SESSION['LOGIN_MSJ']="Please Fill out the required filed";
      header("LOCATION:admin_login_form.php");
      exit();
     }
elseif($username!=$user_verify_query['member_uid'] && $userpass!=$user_verify_query['member_pass'] )
{
    $_SESSION['LOGIN_MSJ']="your username or password donot matched, plz enter corecct";
    header("LOCATION:admin_login_form.php");
    exit();
}
     
elseif($username==$user_verify_query['member_uid'] && $userpass==$user_verify_query['member_pass'] )
{
    $_SESSION['ADMIN_UNAME']=$username;
    $_SESSION['LOGIN_MSJ']="your accounct has been verified. Thanks: $remember";
   if($remember=='yes')
    {
    setcookie('ADMIN_UNAME',$username,time()+3600);
    }
   
    header("LOCATION:index1.php");
    exit();
       
}


?>



  • 0

#2 bbqroast

bbqroast

    Codecall Addict

  • Senior Member
  • PipPipPipPipPipPip
  • 564 posts
  • Location:/etc/passwd

Posted 30 July 2010 - 03:24 PM

Try googling about Cookies, then basicly when you login it gives u a cookie and on INDEX.php the redirect script checks if you have the cookie (and gets user detail from it:: You might want to code in some simple encryption (NOT HARD)) if you dont have the cookie it redirects you.
  • 0
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download