<?php
if (isset($_POST['submit'])) {
session_start();
include('connection.php');
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$hash_password = md5($password);
$sql = "SELECT * FROM users WHERE email = '$email' AND password = '$hash_password' ";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
if ($row['email'] == $email && $row['password'] == $hash_password) {
echo '<script type="text/javascript">';
echo 'setTimeout(function () { sweetAlert("<b>Logged In"," You have successfully loged in.</b>","success");';
echo '}, 500);</script>';
} else {
echo '<script type="text/javascript">';
echo 'setTimeout(function () { sweetAlert("<b>Oops...","Wrong username or Password!...</b>","error");';
echo '}, 500);</script>';
}
}
?>
//database
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8mb4 /;
--
-- Database:
-- Database:
cclv
--
-- Table structure for table
-- Table structure for table
users
CREATE TABLE users
(
id
int(11) NOT NULL,
idnum
varchar(11) NOT NULL,
username
varchar(50) NOT NULL,
year_course
varchar(50) NOT NULL,
mobile
varchar(13) NOT NULL,
department
varchar(50) NOT NULL,
email
varchar(50) NOT NULL,
password
varchar(20) NOT NULL,
date
timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--