Trouble making login page?

Posted by Ken on Stack Overflow See other posts from Stack Overflow or by Ken
Published on 2011-01-09T22:49:26Z Indexed on 2011/01/09 22:53 UTC
Read the original article Hit count: 307

Filed under:
|
|
|

Okay, so I want to make a simple login page. I've created a register page successfully, but i can't get the login thing down.

login.php:

<?php

session_start();

include("mainmenu.php");

$usrname = mysql_real_escape_string($_POST['usrname']);
$password = md5($_POST['password']);

$con = mysql_connect("localhost", "root", "g00dfor@boy");
 if(!$con){
  die(mysql_error());
}

mysql_select_db("users", $con) or die(mysql_error());

$login = "SELECT * FROM `users` WHERE (usrname = '$usrname' AND password = '$password')";
$result = mysql_query($login);

 if(mysql_num_rows($result) == 1 {

    $_SESSION = true;
    header('Location: indexlogin.php');
 }

   else {
echo = "Wrong username or password." ;
}


?>

indexlogin.php just echoes "Login successful." What am I doing wrong? Oh, and just FYI- my database is "users" and my table is "data".

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql