Hey everyone,
The idea of this code is that we have a username/password authentication.
If the username/password is wrong i need to echo in the same page (in Login.php) "Wrong username/password" w/o redirecting.
-Login.php:
<form action="Login.php" method="post" enctype="multipart/form-data">
Member Login
<div id='wrong'></div>
<br />Username<input name="myusername" type="text" id="myusername">
<br />Password<input name="mypassword" type="text" id="mypassword">
<br /><input type="submit" name="Submit" value="Login"></td>
</form>
-Check_Login.php:
<?php
include("Login.php");
$host="localhost";
$username="root";
$password="";
$db_name="projet";
$tbl_name="client";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_start();
$_SESSION['username']= $myusername;
$_SESSION['password']= $mypassword;
header("location:Login_Success.php");
}
else {
echo "<div id=\"wrong\">Wrong username/password</div>";
}
?>
Thanks in advance.
Regards,
Chris ๐