Skip to content

Instantly share code, notes, and snippets.

@NitishDiwakar
Created June 24, 2017 16:47
Show Gist options
  • Save NitishDiwakar/498fae3fc8a50e79e5227f7c6df86d79 to your computer and use it in GitHub Desktop.
Save NitishDiwakar/498fae3fc8a50e79e5227f7c6df86d79 to your computer and use it in GitHub Desktop.
Register and login with php & mysqli using oop
<?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">&times;</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