Mga sir patulong naman po.. ano po mali sa code ..
May error po siya pag wrong password at username..
ito po yung code
<?php
@include 'config.php';
session_start();
if(isset($_POST['submit'])){
$name = mysqli_real_escape_string($conn, $_POST['name']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$pass = md5($_POST['password']);
$cpass = md5($_POST['cpassword']);
$user_type = $_POST['user_type'];
$select = " SELECT * FROM account WHERE email = '$email' && password = '$pass' ";
$result = mysqli_query($conn, $select);
if(mysqli_num_rows($result) > 0){
$row = mysqli_fetch_array($result);
if($row['user_type'] == 'admin'){
$_SESSION['admin_name'] = $row['name'];
header('location:homeadmin.php');
}elseif($row['user_type'] == 'user'){
$_SESSION['user_name'] = $row['name'];
header('location:homeuser.php');
}
}else{
$error[] = 'incorrect email or password!';
}
};
?>
<!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="11style111.css">
<style type="text/css">
*{
font-family: 'Poppins',serif;
margin:20; padding:20;
box-sizing: border-box;
outline: none; border:none;
text-decoration: none;
}
.form-container{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding:50px;
padding-bottom: 80px;
background: #00CED1;
}
.form-container form{
padding:20px;
border-radius: 5px;
box-shadow: 0 5px 10px rgba(0,0,0,.1);
background: #F0E68C;
text-align: center;
width: 500px;
}
.form-container form h3{
font-size: 30px;
text-transform: uppercase;
margin-bottom: 10px;
color:#333;
}
.form-container form input,
.form-container form select{
width: 100%;
padding:10px 15px;
font-size: 17px;
margin:8px 0;
background: #eee;
border-radius: 5px;
}
.form-container form select option{
background: #fff;
}
.form-container form .form-btn{
background: #fbd0d9;
color:crimson;
text-transform: capitalize;
font-size: 40px;
cursor: pointer;
}
.form-container form .form-btn:hover{
background:#7CFC00;
color:#000000;
}
.form-container form p{
margin-top: 10px;
font-size: 15px;
color:#333;
}
.form-container form p a{
color:crimson;
}
.form-container form .error-msg{
margin:10px 0;
display: block;
background: crimson;
color:#F0FFFF;
border-radius: 5px;
font-size: 20px;
padding:10px;
}
</style>
</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="email" name="email" required placeholder="enter your email">
<input type="password" name="password" required placeholder="enter your password">
<input type="submit" name="submit" value="login now" class="form-btn">
<p>don't have an account? <a href="register_form.php">register now</a></p>
</form>
</div>
</body>
</html>
May error po siya pag wrong password at username..
ito po yung code
<?php
@include 'config.php';
session_start();
if(isset($_POST['submit'])){
$name = mysqli_real_escape_string($conn, $_POST['name']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$pass = md5($_POST['password']);
$cpass = md5($_POST['cpassword']);
$user_type = $_POST['user_type'];
$select = " SELECT * FROM account WHERE email = '$email' && password = '$pass' ";
$result = mysqli_query($conn, $select);
if(mysqli_num_rows($result) > 0){
$row = mysqli_fetch_array($result);
if($row['user_type'] == 'admin'){
$_SESSION['admin_name'] = $row['name'];
header('location:homeadmin.php');
}elseif($row['user_type'] == 'user'){
$_SESSION['user_name'] = $row['name'];
header('location:homeuser.php');
}
}else{
$error[] = 'incorrect email or password!';
}
};
?>
<!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="11style111.css">
<style type="text/css">
*{
font-family: 'Poppins',serif;
margin:20; padding:20;
box-sizing: border-box;
outline: none; border:none;
text-decoration: none;
}
.form-container{
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding:50px;
padding-bottom: 80px;
background: #00CED1;
}
.form-container form{
padding:20px;
border-radius: 5px;
box-shadow: 0 5px 10px rgba(0,0,0,.1);
background: #F0E68C;
text-align: center;
width: 500px;
}
.form-container form h3{
font-size: 30px;
text-transform: uppercase;
margin-bottom: 10px;
color:#333;
}
.form-container form input,
.form-container form select{
width: 100%;
padding:10px 15px;
font-size: 17px;
margin:8px 0;
background: #eee;
border-radius: 5px;
}
.form-container form select option{
background: #fff;
}
.form-container form .form-btn{
background: #fbd0d9;
color:crimson;
text-transform: capitalize;
font-size: 40px;
cursor: pointer;
}
.form-container form .form-btn:hover{
background:#7CFC00;
color:#000000;
}
.form-container form p{
margin-top: 10px;
font-size: 15px;
color:#333;
}
.form-container form p a{
color:crimson;
}
.form-container form .error-msg{
margin:10px 0;
display: block;
background: crimson;
color:#F0FFFF;
border-radius: 5px;
font-size: 20px;
padding:10px;
}
</style>
</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="email" name="email" required placeholder="enter your email">
<input type="password" name="password" required placeholder="enter your password">
<input type="submit" name="submit" value="login now" class="form-btn">
<p>don't have an account? <a href="register_form.php">register now</a></p>
</form>
</div>
</body>
</html>
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.