SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: log in error

  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    log in error

    Hi guys. Im getting this error message

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.


    Here is my code. Many thanks if you can help me with the problem



    <?
    session_start();
    ob_start();
    require_once('includes/mysql_connect.php');

    if(isset($_SESSION['username']) && isset($_SESSION['password'])) {
    //REDIRECT TO USERS PROFILE...
    header("Location: myaccount.php");
    exit;
    } //end if logged in

    //IF SUBMIT BUTTON PRESSED
    if(isset($_POST['submit'])) {

    if(!$_POST['username']) die("Error: You must enter your username before logging in.");
    if(!$_POST['password']) die("Error: You must enter your password before logging in.");

    //set cookie if checked
    if(!empty($_POST['stay_in'])) {
    $joined =''.$_POST['username'].'[]'.md5($_POST['password']).'';
    setcookie('login_cookie', $joined, 2147483647, '/', '.www.yoursite.com');
    } //end if

    //verify user...
    $get_user = mysql_query("SELECT * FROM `members` WHERE username = '".$_POST['username']."' AND password = '".md5($_POST['password'])."' limit 1");
    $q = mysql_fetch_object($get_user);
    if(!$q) die("Login Failure: An error occured, please verify your username and password are correct.");

    //set session variables
    $_SESSION['logged_in'] = $q['user_id'];
    $_SESSION['username'] = $_POST['username'];
    $_SESSION['password'] = $_POST['password'];
    session_write_close();

    header("Location: myaccount.php");
    exit;
    } else {
    //show login form
    ?>

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something on myaccount.php must be redirecting the user back to this script. Thus an infinite loop.

    Probably if a session username and password are set (but incorrect) the loop will be infinite.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Cranial

    I have fixed it with your advice


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
  •