Created
June 24, 2017 16:47
-
-
Save NitishDiwakar/498fae3fc8a50e79e5227f7c6df86d79 to your computer and use it in GitHub Desktop.
Register and login with php & mysqli using oop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filename: include/login.php | |
session_start(); | |
include 'class.user.php'; | |
if (isset($_REQUEST['login'])) { | |
$user = new User(); | |
extract($_REQUEST); | |
$login = $user->check_login($emailusername, $password); | |
if ($login) { | |
// Registration Success | |
header("location: ../home.php"); | |
// echo '<script>window.location = "../home.php"</script>'; | |
exit(); | |
} else { | |
// Registration Failed | |
// echo 'Wrong username or password'; | |
$_SESSION['msg'] = '<div class="alert alert-danger alert-dismissable"> | |
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
<strong>Unable to login</strong>! Wrong username/email or password. | |
</div>'; | |
header("location: ../login.php"); | |
exit(); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment