1
I am trying to generate the login according to the database data and proceed to the page restricted to registered users, but there is incorrect password error.
Front-end:
<div class="login-form">
<form action="modulo.php" method="POST">
<input type="email" placeholder="E-mail" value="email" >
<input type="password" placeholder="Senha" value="password" >
<input type="submit" class="btn-submit" value="Login">
</div>
Back-end
<?php
session_start();
// error_reporting('1');
include 'config.php';
// username and password sent from form
$myusername=$_POST['email'];
$mypassword=$_POST['password'];
// 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 login WHERE email='$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 "menu.php"
$_SESSION['email']=$myusername;
$_SESSION['password']=$mypassword;
header("location:menu.php");
}
else {
echo "<b class='error'>Wrong Username or Password</b>";
}
?>
Give a print_r($_POST) in the file that receives the data and put here.
– touchmx