Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Roger Dailey
Roger Dailey
14,887 Points

I need help with figuring out what I am doing wrong with my login page?

I am lost, do not know what I am doing wrong?

<?php
session_start();

require("connect_db.php");
include('login_header.php');

if($_POST['login_btn']) {
    $username = strip_tags($_POST['username']);
    $password = strip_tags($_POST['password']);

    $username = stripslashes($username);
    $password = stripslashes($password);

    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

    $result = mysql_query("SELECT * FROM client WHERE username = '$username' AND password = '$password'");
    $row = mysql_fetch_assoc($result);
    if($row['username'] == $username && $row['password'] == $password) {
        echo 'logged in';
    } else {
        echo 'Username/Password invalid!';
    }
}
?>

1 Answer