Last active
June 24, 2017 16:48
-
-
Save NitishDiwakar/0e3a996f3b773dfc7199e3c27f5a71e8 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/register.php | |
session_start(); | |
//n | |
include 'class.user.php'; | |
$user = new User(); // Checking for user logged in or not | |
if (isset($_REQUEST['register'])){ | |
extract($_REQUEST); | |
$register = $user->reg_user($fullname, $uname,$upass, $uemail); | |
if ($register) { | |
// Registration Success | |
// echo 'Registration successful <a href="login.php">Click here</a> to login'; | |
$_SESSION['msg'] = '<div class="alert alert-success alert-dismissable"> | |
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
<strong>Success</strong>! Registration successful. <a href="login.php">Click here</a> to login. | |
</div>'; | |
header("location: ../registration.php"); | |
exit(); | |
} else { | |
// Registration Failed | |
// echo 'Registration failed. Email or Username already exits please try again'; | |
$_SESSION['msg'] = '<div class="alert alert-danger alert-dismissable"> | |
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a> | |
<strong>Registration failed</strong>! Email or Username already exists. | |
</div>'; | |
header("location: ../registration.php"); | |
exit(); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment