Skip to content

Instantly share code, notes, and snippets.

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