SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    907
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with successful login in area

    Im creating a log in screen, and all seems to be fine excpet when the user is successful, I get a error 500 screen and cant see what the problem is.

    http://www.whhazardreport.co.uk/mana...n/indexLee.php

    Username: admin
    Password: admin

    Code:
    <?php
    //Start session.	
    session_start();
    error_reporting(E_ALL);
    ini_set('display_errors','On');
    //Include database connection details.
    require_once('../config.php');
    //Array to store validation errors.	
    $errmsg_arr = array();
    //Validation error flag
    $errflag = false;
    //Function to sanitize values received from the form. Prevents SQL injection
    function clean($str) {
    $str = @trim($str);
    if(get_magic_quotes_gpc()) {
    $str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
    }
    //Sanitize the POST values
    $username = clean($_POST['username']);
    $password = clean($_POST['password']);
    //Input Validations
    if($username == '') {
    $errmsg_arr[] = 'Username missing';
    $errflag = true;
    }
    if($password == '') {
    $errmsg_arr[] = 'Password missing';
    $errflag = true;
    }
    //If there are input validations, redirect back to the login form
    if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: indexLee.php");
    exit();
    }
    This is the bit im thinking there is a problem

    Code:
    //Create query
    $qry="SELECT * FROM UserAdmin WHERE username='".$username."' AND password='".$password."'";
    $result=mysql_query($qry);
    //Check whether the query was successful or not
    if($result) {
    if(mysql_num_rows($result) > 0) {
    	echo "Lee";
    //Login Successful
    session_regenerate_id();
    $member = mysql_fetch_assoc($result);
    $_SESSION['SESS_MEMBER_ID'] = $member['admin_ID'];
    $_SESSION['SESS_FIRST_NAME'] = $member['username'];
    $_SESSION['SESS_LAST_NAME'] = $member['password'];
    session_write_close();
    header("location: home.php");
    exit();
    And this is the rest of the code

    Code:
    }else {
    //Login failed
    $errmsg_arr[] = 'user name and password not found';
    $errflag = true;
    if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: indexLee.php");
    exit();
    }
    }
    }else {
    die("Query failed");
    }
    ?>

  2. #2
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    907
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I just tested it in Firefox and it works fine, so it seems to be a IE 9 error. Well on the PC I'm using it is anyway.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    907
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I seem to have sorted it, by playing with the code that authenticates the username password on the page that the user intends to go to.

    Thanks

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,127
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by multichild View Post
    OK I seem to have sorted it, by playing with the code that authenticates the username password on the page that the user intends to go to.

    Thanks
    Can you elaborate as to what the issue was? As I took a quick glance and didn't notice anything obvious.


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
  •