<?php
//@include 'config.php';
session_start();
if(isset($_POST['submit'])){
$email = $_POST['email'];
$pass = $_POST['password'];
$t=0;
//$cpass = md5($_POST['cpassword']);
//$user_type = $_POST['user_type'];
$filename = "pass.php";
if (file_exists($filename)) {
$fp = fopen($filename, "r"); //m? file ? ch? ?? ??c
$line = file($filename); //gan tat ca dong trong file vao mang $line
for ($row = 0; $row < (int)count($line) ; $row++){
$ma = trim(strval(str_replace(' ','',(explode("nhc",$line[$row])[2]))));
$pas= trim(strval(str_replace(' ','',(explode("nhc",$line[$row])[3]))));
$ten= trim(strval(str_replace(' ','',(explode("nhc",$line[$row])[1]))));
//$tg = array(explode("nhc",$line[$row])[1] => explode("nhc",$line[$row])[3]);
if(($email==$ma || $email== $ten) && $pass==$pas)
{
$_SESSION['admin_name'] = $ma;
header('location:index.php');
$t++;
break;
}
else{
$t = 0;
}
}
if($t==0){$error[] = 'incorrect email or password!';}
}
fclose($fp);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login form</title>
<!-- custom css file link -->
<link rel="stylesheet" href="style1.css">
</head>
<body>
<div class="form-container">
<form action="" method="post">
<h3>login now</h3>
<?php
if(isset($error)){
foreach($error as $error){
echo '<span class="error-msg">'.$error.'</span>';
};
};
?>
<input type="text" name="email" required placeholder="[email protected]">
<input type="password" name="password" required placeholder="aa">
<input type="submit" name="submit" value="login now" class="form-btn">
<p>B?n ch?a có account? <a href="register_form.php">register now</a></p>
</form>
</div>
</body>
</html>
|