0

hello friends,

i am a newbie in php.. doing project for my college. doing it with a lot of help with this site n some others but stuck in the login page, it seems either there is some problem in databse connection or session registration.. when i put username n password it returns me to that login page again.. can anyone help me to identify the problem.. i am using Dreamweaver editor n xampp as server

<?php
 session_start();
 session_register("is_logged_in");
$myusername=$_POST['uid']; 
$mypassword=md5($_POST['pass']);
if (!isset($myusername) || !isset($mypassword)) { 
header( "Location: http://localhost/XXX/index.html" ); 
exit;
}
elseif (empty($myusername) || empty($mypassword)) { 
header( "Location: http://localhost/XXX/index.htmll" ); 
exit;
}
else{	
$host="localhost"; // Host name 
$username="Aritra"; // Mysql username 
$password="******";//Mysql password
$db_name="****"; // Database name 
$tbl_name="login_details"; // Table name
$db_connect=mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DataBase");
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE login_id='$myusername' and passwd='md5($mypassword)'";
$result=mysql_query($sql, $db_connect);
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count>0){
$_SESSION['is_logged_in'] = 1;
}
if(!isset($_SESSION['is_logged_in'])) {
	header("location:./download.html");
	exit;
} else {
    header("location:http://localhost/XXX/index.html");
	exit();
}
}
 ?>
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by lll_ari_lll
0

srry guys, its my fault. i have forgotten to declare privilege to the user in database.. now its working..

sorry for wasting ur time.
mods r requested to delete this thread

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.