Associate
- Joined
- 13 Jul 2005
- Posts
- 738
- Location
- Brisbane
Hi, i am trying to login and redirect the successful login to main.php, but everytime i try the below 'logincheck.php' code, i receive the error code, even though i know the username and password details are correct.
Code:
help will be much appreciated.
Tucks
Code:
Code:
<? //logincheck.php
//start the session
session_start();
//include java error file
include 'common.php';
//include connection file
include 'db.php';
// Connect to database 'sms'
dbConnect('epicfx00_sms');
// username and password sent from signup form
$username = $_POST['uname'];
$password = $_POST['upassword'];
$password=md5($password);
$sql="SELECT * FROM user WHERE userid='$username' and password='$password'";
$result=mysql_query($sql) or die(mysql_error());
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword and $myemail, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword, $myemail and redirect to file "login_success.php"
session_register("username");
session_register("password");
header("Location:main.php");
}
else {
error('Either your username or password were incorrect, please go back and try again');
}
?>
help will be much appreciated.
Tucks