Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Posts posted by budimir

  1. OK, that's good.

     

    Now, remove your die; from the script.

     

    And echo the $num_rows to see if you getting the correct number of records.

     

    Also

    if( $num_rows  > 0 )
    {
    	$_SESSION['username'] = $username;  
    	//redirect
    	$data = mysql_fetch_array($results);
    echo "$data['company']";  //take this so we could see if your getting the correct value
    
    	header("Location: {$data['company']}.php"); 		
    }

  2. No, you need to put it outside an if statment.

     

    Put it immediatly after this line:

     

    $sql = "SELECT * FROM access WHERE username='" . $username . "' and company = '" . $company . "'";
    echo "$sql"; //This will show the query
    die;  // This will stop the script from executing further on and it will be easier to see the result of the query
    $result = mysql_query($sql,$link) or die(mysql_error());
    $num_rows = mysql_num_rows($result); 

  3. If I don't need the

    include( 'sessions.php' );

    on the login check page then do I need it on the

    login page where they submit their username and pw?

     

     

     

    No, you need, 

    include( 'sessions.php' );

    , on every page after a user has been loged in. In this file you can keep all the data about your user and the session.

  4. OK, so let's rework your code a little bit!

     

    Do it like this:

     

    $sql = "SELECT * FROM access WHERE username='" . $username . "' and company = '" . $company . "'";
    $result = mysql_query($sql,$link) or die(mysql_error());
    $num_rows = mysql_num_rows($result); 

     

    and then you put:

    echo "$sql";

     

    So we could see what is happening with you query and then will see if you're getting the correct values.

  5. Can you echo your query, so we could see if it's getting all the variables it needs??

     

    Also, remove include ('sessions.php'); form loign check page, you don't need it there since you didn't start you're session yet.

     

    Also check if your getting anything in variables $username and $company!!!

  6. Hey, yes he meant to put both codes to one page, but that could be confusing. Try to do it like this, it will be much easier and easier to track the problems.

     

    1.) Create a login.php page where a User needs to put his username and pass

    2.) Create a checklogin.php page where you will check if the user was found and redirect him to the page where he needs to go

    3.) Create a session.php page where you will start your session() and kepp all the info about the session for that user (you need to include session.php to the top of each page and then when someone wnats to copy and paste the link it will be redirected to the logout page)

     

    I hope it gave I little bit clearer picture!

  7. Hey guys,

     

    Why isn't this script working? It's a script for redirecting to antoher file depending on the resoultion. But when I load a file it just does nothing.

     

    <SCRIPT language="JavaScript">
    <!--
    if ((screen.width >= 1024) && (screen.height >= 768)) {
    window.location="index.php";
    } else {
    window.location="index_glavni_m.php";
    }
    //-->
    </SCRIPT>

     

    Help, please!!!!!

  8. You're posting your question on a wrong forum. You have a section for this.

     

    I assume that you are asking how to protect access to the phpmyadmin, or something like that

     

    For phpmyadmin, you need to access config.inc.php and change line number 71 to

    $cfg['Servers'][$i]['auth_type']     = 'http'; 

     

    So when you try to access phpmyadmin it will pop up a window and ask you for the username and password.

     

    Correct me if I have missunterstood?

  9. You can not echo a connection to the DB!

     

    The error message you can put

    $epikcon = mysql_pconnect($hostname_epikcon, $username_epikcon, $password_epikcon) or die (mysql_error());

     

    So, if the program doesn't stop here, your connection is successfull.

  10. can you please stop bumping the thread. And when you run the browser again, are you restoring the page .

    e.g. firefox says restore previus session, and this sets all the sessions as they where when it was closed.

     

    No, I'm not doing that! I start clean FireFox and session is still in. Same thing happens with the IE7.

  11. Here is my check_login.php

     

    <?php
    session_start();
    
    include ("admin/servis/include/db.php");
    
    // Define $myusername and $mypassword 
    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['mypassword']; 
    
    $sql="SELECT * FROM korisnici WHERE korisnicko_ime='$myusername' and lozinka='$mypassword'";
    $result=mysql_query($sql) or die (mysql_error());
    
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1){
    $upd = "UPDATE korisnici SET session_id='".session_id()."', aktivan = 'ON' WHERE korisnicko_ime='$myusername' and lozinka='$mypassword'";
    mysql_query($upd) or die (mysql_error());
    
    header("location:index_glavni.php");
    exit;
    }
    else {
    echo "Upisali ste krivo Korisničko ime ili Lozinku!";
    }
    
    ?>

     

    And here is my session.php

     

    <?php
    session_start();
    $session_id = session_id();
    
    include("db.php");
    
    $upit = "SELECT * FROM korisnici WHERE session_id = '$session_id' && aktivan = 'ON'";
    $rezultat = mysql_query($upit,$veza) or die (mysql_error());
    $row = mysql_fetch_array($rezultat);
    $user_id = $row["id"];
    $ime = $row["ime"];
    $korisnicko_ime = $row["korisnicko_ime"];
    $prezime = $row["prezime"];
    $userData["status"] = $row["status"];
    $lozinka = $row["lozinka"];
    $status = $row["status"];
    $aktivan = $row["aktivan"];
    $sesija_id = $row["session_id"];
    
    if (!$user_id){
    header("Location:../../logoutd.php");
    exit;
    }
    
    $_SESSION['session_time'] = time(); //got the login time for user in second
    $session_logout = 90; //it means 15 minutes.
    //and then cek the time session
    if($session_logout >= $_SESSION['session_time']){
           //user session time is up
           // update status
       $upit = "UPDATE korisnici SET session_id = '0', aktivan = 'OFF' WHERE korisnicko_ime='$korisnicko_ime' and lozinka='$lozinka'";
       $rezultat = mysql_query($upit,$veza) or die (mysql_error());
           //destroy the session
           session_destroy();
    //redirect to login page
    header("Location:../../../index.php");
    exit;
    }
    ?>

     

    Why is not loging out, when I close my browser????

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.