Results 1 to 3 of 3

Thread: Login Script Problems

  1. #1
    Join Date
    Sep 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Login Script Problems

    hey guys,

    I have a script which is :

    PHP Code:
    <?php
    include "connection.php";

    // Connect to server and select databse.
    if (!$con)
      {
      die(
    'Could not connect: ' mysql_error() );
      }
      
    mysql_select_db($db$con);

    // username and password sent from signup form 
    $user=$_POST['myusername']; 
    $pass=$_POST['password']; 

    $sql="SELECT * FROM our_info WHERE username='$user' and password='$pass'";
    $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 $user, $pass and redirect to file "failed.html"
    session_register("$user");
    session_register("$pass"); 
    header("location:../main.php");
    }
    else {
    header("location:../failed.html");
    }
    ?>
    and then on the next page i have this:

    PHP Code:
    <?  
    session_start
    (); 
    $t date("h:i:s"time()); 
    $_SESSION['admin_login_time'] = $t
    $_SESSION['myusername'] = $user
    if(!
    session_is_registered(myusername)){ 
    header("location:index.php"); 

    ?>
    Why doesnt it display the $user and how do i get it to show the login time rather than the current time?

  2. #2
    Join Date
    Sep 2006
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    can anyone help?

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    session_register() is pretty much deprecated now. Just call session_start() and write to the $_SESSION array.
    Code:
    $user=$_POST['myusername'];  
    $pass=$_POST['password'];  
     
    $sql="SELECT * FROM our_info WHERE username='$user' and password='$pass'";
    SQL injection vulnerability. You forgot to validate your input.
    Code:
    header("location:../main.php");
    The value of the Location header must be an absolute URL.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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