لدي صفحة تسجيل دخول بالايميل وكلمة السر عندما اقوم بتسجيل الدخول يتم الدخول بشكل طبيعي ولكن اذا عملت للصفحة تحديث او ريفرش يقوم بمطالبتي مرة اخرى بمعلومات الدخول وهكذا او ذهبت لصفحة اخرة وعدت الى الموقع يطالبني بمعلومات الدخول فكيف الحل ???:
<?php
@include 'config.php';
session_start();
if(isset($_POST['submit'])){
$email = $_POST['email'];
$email = filter_var($email, FILTER_SANITIZE_STRING);
$pass = md5($_POST['pass']);
$pass = filter_var($pass, FILTER_SANITIZE_STRING);
$sql = "SELECT * FROM `users` WHERE email = ? AND password = ?";
$stmt = $conn->prepare($sql);
$stmt->execute([$email, $pass]);
$rowCount = $stmt->rowCount();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if($rowCount > 0){
if($row['user_type'] == 'admin'){
$_SESSION['admin_id'] = $row['id'];
header('location:admin_page.php');
}elseif($row['user_type'] == 'user'){
$_SESSION['user_id'] = $row['id'];
header('location:home.php');
}else{
$message[] = 'no user found!';
}
}else{
$message[] = 'incorrect email or password!';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="icon/moh.png" type="image/png">
<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>تسجيل دخول</title>
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.co...">
<meta http-equiv="Content-Security-Policy" content="script-src 'none'">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'">
<!-- custom css file link -->
<link rel="stylesheet" href="css/components.css">
<script nonce="random123" src="https://www.soqhra.com/js/s..."></script>
</head>
<body>
<?php
if(isset($message)){
foreach($message as $message){
echo '
<div class="message">
<span>'.$message.'</span>
<i class="fas fa-times" onclick="this.parentElement.remove();"></i>
</div>
';
}
}
?>
<section class="form-container">
<form action="" method="POST">
<h3>login now</h3>
<input type="email" name="email" class="box" placeholder="enter your email" required>
<input type="password" name="pass" class="box" placeholder="enter your password" required>
<input type="submit" value="login now" class="btn" name="submit">
<p>don't have an account? <a href="register.php">register now</a></p>
</form>
</section>
</body>
</html>
التعليقات