hi all,
i have created one simple login form to verify only username and password.i have created username as admin and password as admin123 in phpmyadmin database.
now if only both the username and password matches then it should display success message.
but for me after giving username name as admin and password as admin123 it is asking for “whether to save or download the file” instead of displaying the message as “login is successfull”.why it is asking that one.whats woron in my code…
below is my code…
login.html
<form name="form1" method="post" action="checklogin.php">
<strong>Member Login </strong>
</br>
Username: <input name="myusername" type="text" id="myusername" />
</br>
Password: <input name="mypassword" type="password" id="mypassword" />
</br>
<input type="submit" name="Submit" value="Login" />
</form>
it is checklogin.php
<?php
// Connect to server and select databse.
mysql_connect("localhost", "root", "")or die("cannot connect");
mysql_select_db("test")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM users WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else
{
echo "Wrong Username or Password";
}
?>
it is login_success.php
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>
tell me what went wrong