Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Problems in Login Forms...

$
0
0
i Made a function look like this

PHP Code:

function login($username){
$log_query="select * from users where u_name='$username'";
$query_log=mysql_query($log_query) or die (mysql_error());
while(
$log_row=mysql_fetch_array($query_log)){
global 
$u_id,$u_name,$u_pass,$u_status;
$u_id=$log_row['u_id'];
$u_name=$log_row['u_name'];
$u_pass=$log_row['u_pass'];
$u_status=$log_row['u_status'];
}


and make a file login.php look like this

PHP Code:

session_start();
require_once 
'config.php';
require_once 
'functions.php';
$post_user_name=trim($_POST['username']);
$post_user_pass=trim($_POST['password']);
if(isset(
$post_user_name,$post_user_pass)){
login($post_user_name);
if(
$post_user_name==$u_name && $post_user_pass==$u_pass && $u_status=='y'){

$_SESSION['s_user']=$session_user;
header("location:index.php");
}
else
{
$user_not_match="Username or Password Incorrect";
}
}
else
{
//$user_pass_empty=
echo "Username and Password Must Fill";


and in the index.php file i use this code

PHP Code:

session_start();
require_once 
'config.php';
require_once 
'functions.php';
all_set();
if(isset(
$_SESSION['s_user'])){
$s_user_msg="Login as".$_SESSION['s_user'];
$user_session=$_SESSION['s_user'];
$set_key=1;
}
else{
$set_key=0;


when i login it redirects but this code is not working...

PHP Code:

if(isset($set_key)){
            if(
$set_key==0){
            
?> 

then a form code goes here

PHP Code:

}
          elseif(
$set_key==1){
          echo 
$user_session;
          }
          } 


Viewing all articles
Browse latest Browse all 13329

Trending Articles