www.webdeveloper.com
Results 1 to 2 of 2

Thread: sessions

  1. #1
    Join Date
    Sep 2013
    Posts
    18

    sessions

    this is my login code....!

    this working for login....

    once iím logid in... it will redirect tooo dash.php page.. that 1 is my home page... in this page login information is not shown...!

    based on this session and details... how to continue this session to all pages...

    username: un
    table name: emp_table
    name: nm
    email: eml

    this is login.php



    <?php
    session_start();
    extract($_POST);
    extract($_GET);
    mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("shift_planning") or die(mysql_error());



    function validate_user($un, $pw){
    $select_query = "Select * from emp_table where un='".$un."' and pw='".$pw."'";
    $select_result = mysql_query($select_query);
    return $select_result;
    }

    if(isset($_POST['login_submit'])){



    $validate_result = validate_user($un, $pw);



    if(mysql_num_rows($validate_result) != 0)
    {
    $user_result = mysql_fetch_array($validate_result);
    $_SESSION['logged_user'] = $user_result['un'];

    echo "<meta http-equiv=\"refresh\" content=\"0;URL=dash.php\">";
    }
    else
    {
    echo "<meta http-equiv=\"refresh\" content=\"0;URL=login.php\">";
    echo "<script>alert('Login Failed! Please Enter Valid Username and Password.')</script>";
    }
    }



    ?>






    and this one is. for session continue code... but not working...




    <?php
    function get_user_info_by_id($id){
    $select_query = "Select * from emp_table where un=$un";
    $select_result = mysql_query($select_query);
    $result = "";

    if (mysql_num_rows($select_result) != 0) {
    return $select_result;
    }else{
    return $result;
    }
    }
    ?>
    <?php

    if(isset($_SESSION['logged_user'])) {
    $user_res = get_user_info_by_id($_SESSION['logged_user']);
    $user_info = mysql_fetch_array($user_res);

    ?>
    <a href=""><?php echo ucwords($user_info['nm'])." ". ucwords($user_info['un']); ?>

    <?php } else { ?>

    <a href="index.php" class="signin">Login</a>


    <?php } ?>


    please help me

  2. #2
    Join Date
    Jul 2013
    Posts
    351
    Have you looked at the page sent to the client? It looks flawed here. Your anchor tag showing the contents of $user_info is not closed. Furthermore your href is non-existent.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles