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.

Member Avatar for Zagga

Hi prayag.419,

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

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.