0

I want to create login form
here is the code

// login.html


<html>
<head>
<title>Login</title>
</head>


<form name="Login" method="post" action="loginbackend.php">
Username : <input name="txtUname" type="text" id="Uname"><br />
Password : <input name="txtUpass" type="password" id="Upass"><br />
<input type="submit" name="Submit" value="Login">



</form>
</html>


// loginbackend.php


<?php


ob_start();


$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '123';            //root password
$dbname = 'login';          //database name
$tbl_name = 'user_passs';   //table name



// to connect to MYSQL
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');


// to connect to database
mysql_select_db($dbname);


// getting user name and password
$username = $_POST;
$userpass = $_POST;


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


// Firing the query


$check = "SELECT * FROM $tbl_name WHERE uname = $username AND upass = $userpass";
$result = mysql_query($check);


$count = mysql_num_rows($result);


if($count==1)
{
session_start();
session_register('authorized');
$_SESSION = true;


header("location:successful.php");
exit;
}
else
{
header("location:failed.html");
exit;
}



mysql_close($conn);


ob_end_flush();


?>

this code is not working. Can any 1 help me.

Edited by happygeek: fixed formatting

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by vinayakgarg
0

Hi prayag.419,

What exactly is not working with the script? What error messages are you getting?

0

error msg is not comming, but a download dialog box is opening and asking me to download the loginbackend.php file which i have created.

Did you get my it ?
if yes plz give the solution for it.

regards.

0

I guess the problem lies with browser. Which browser are you using.
The same html file works fine on my firefox (but not on my IE8).
Vinayak

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.