Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Right now i'm trying to implement a tutorial on displaying online users with my existing login system. I have try'd virtually every possibility and it just won't work. I need help from some experienced members that are good with php. This is still all a learning experience for me. As of right now what happens when I try to login is it redirects me to my cannot connect page(index.php page)

    Thanks in advance!
    Entire zipped site included in attachments.

    EDIT: test site http://sot.web44.net/index.php

    EDIT 2: test login details are
    Username: test
    Password: test
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    In the script called "checklogin.php", add the lines (shown in red) to test if any results were found when they logged in:

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    echo "Results Found: $count";
    exit;

    You're adding those two lines just for testing. It should say, Results Found: 1

    That will at least test if the query is working for username and password.
    Let me know what you discover ... does it work or not?

    EDIT:
    I also don't know what this script does: navigation.php

    You're writing the $_POST username into the mysql table? Not sure why, and you're missing session_start();


  4. #3
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by mlseim, post: 247252
    In the script called "checklogin.php", add the lines (shown in red) to test if any results were found when they logged in:

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    echo "Results Found: $count";
    exit;

    You're adding those two lines just for testing. It should say, Results Found: 1

    That will at least test if the query is working for username and password.
    Let me know what you discover ... does it work or not?

    EDIT:
    I also don't know what this script does: navigation.php

    You're writing the $_POST username into the mysql table? Not sure why, and you're missing session_start();
    Going to test what you said soon. The navigation.php is from the tutorial i mentioned. This puts the user that logged in into the "members" table in my mysql. This is what will be called too show the currently logged in members.

    EDIT: The login system WAS working before I did all this other stuff. I was able to log in and log out with no porblems.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    So you have two tables ...

    One table is the real members table that contains their username, password, email, etc
    The other "members table" is constantly changing ... showing which members are logged in?

    I assume those two tables have different names?
    It looks to me like they have the same name, and that's what I'm confused about.

    You say it worked BEFORE you "did all this stuff". By "stuff", you mean adding the part about which members are currently logged in?


  6. #5
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by mlseim, post: 247267
    So you have two tables ...

    One table is the real members table that contains their username, password, email, etc
    The other "members table" is constantly changing ... showing which members are logged in?

    I assume those two tables have different names?
    It looks to me like they have the same name, and that's what I'm confused about.

    You say it worked BEFORE you "did all this stuff". By "stuff", you mean adding the part about which members are currently logged in?
    Yes the log in system worked perfectly before I tried this new stuff im doing now. The tutorial that im following does not include a table with existing members which confused me so I am trying to use one table instead of two. My table is named "members" it contains rows that are: "username" "password" "time"

    the row "time" is a DATETIME value which is what will be pulled to show the latest active members based on the time they last used the website on any page.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Get it back to where you were before it failed. Get the login working again and then we'll revisit the part you tried to add.


  8. #7
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by mlseim, post: 247279
    Get it back to where you were before it failed. Get the login working again and then we'll revisit the part you tried to add.
    Well do. Thanks for all the help by the way
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  9. #8
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by mlseim, post: 247279
    Get it back to where you were before it failed. Get the login working again and then we'll revisit the part you tried to add.
    Ok I got it back to where it was before but now something isn't right... I put in the code you suggested to test if its connectin.

    echo "Results Found: $count";
    exit;

    It shows Result Found: 1

    But when I get rid of that code it justed redirects me to my index page when I try to log in.
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Post only the "checklogin.php" script here.
    I want to see that first.


  11. #10
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    Quote Originally Posted by mlseim, post: 247297
    Post only the "checklogin.php" script here.
    I want to see that first.
    Code:
    <?php
    session_start();
    
    $host="mysql1.000webhost.com"; // Host name
    $username="a7921734_test"; // Mysql username
    $password="hacked123"; // Mysql password
    $db_name="a7921734_test"; // Database name
    $tbl_name="members"; // Table name
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // username and password sent from form
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];
    
    // To protect MySQL injection (more detail about MySQL injection)
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);
    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    
    // 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){
    
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    $_SESSION['username']=$myusername;
    // session_register("username");
    // session_register("password");
    header("location:/index_logged.php");
    }
    
    else {
    echo '<META HTTP-EQUIV="Refresh" Content="0; URL=/index.php">';
    }
    ?>
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs




Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:05 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com