Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    19

    Unanswered: Problems in Login Forms...

    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;
              }
              } 

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Your problem isn't clear.

    How are you passing/getting/setting the value of $set_key in each page?
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2012
    Posts
    19
    i do solve my problem but for the info of other ...
    you ask question how do i set key
    set key i do for when user login a set key is generated like 1... same like user session just work like session key... so i can easily compare in my all file like ...


    if (isset($set_key==1)) {
    show the user a message }

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    That doesn't look like a session variable to me...

    This would be a session variable.
    Code:
    $_SESSION["set_key"] = 1;
    What you're using is a standard variable, which "loses" its value between scripts. Therefore you can't set the value in file1.php and expect to retrieve that value in file2.php.
    George
    Home | Blog

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Depending on who you talk to php session variables can be deemed as cookies and as such if your app is to be used within the eu will fall foul of the legislation banning the use of cookies without the express consent of the user.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •