-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functional Custom Registration and Login System
- Loading branch information
Showing
6 changed files
with
152 additions
and
52 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>myLife - Register</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.css"/> | ||
<link href="https://fonts.googleapis.com/css?family=Manjari&display=swap" rel="stylesheet"> | ||
|
||
|
||
</head> | ||
<body> | ||
<div class ="container"> | ||
<div class = "row"> | ||
<div class = "col-lg-6 m-auto"> | ||
<div class = "card bg-light mt-5"> | ||
<div class="card-title bg-success text-white mt-5"> | ||
<h3 class="text-center py-3" style="font-family: 'Manjari', sans-serif;">Register a myLife Account</h3> | ||
</div> | ||
|
||
<?php | ||
if($_GET['Invalid'] == true) | ||
{ | ||
?> | ||
<div class="alert-light text-danger text-center py-3"><?php echo $_GET['Invalid']?></div> | ||
<?php | ||
} | ||
?> | ||
|
||
|
||
<div class="card-body"> | ||
<form action="../php/register.php" method="post"> | ||
<input type="text" name="firstname" placeholder="First Name" class="form-control mb-4"> | ||
<input type="text" name="lastname" placeholder="Last Name" class="form-control mb-4"> | ||
<input type="text" name="email" placeholder="Email" class="form-control mb-4"> | ||
<input type="text" name="UName" placeholder="Username" class="form-control mb-4"> | ||
<input type="password" name="Password" placeholder="Password" class="form-control mb-4"> | ||
<input type="password" name="ConfirmPassword" placeholder="Confirm Password" class="form-control mb-4"> | ||
<button class="btn btn-success" name="Register">Register</button> | ||
<br/> | ||
<a href="../index.php">Already have an account? Sign in here</a> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="js/jquery-3.3.1.slim.min.js"></script> | ||
<script src="js/popper.min.js"></script> | ||
<script src="bootstrap-4.1.0/js/bootstrap.min.js"></script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
session_start(); | ||
require_once('config.php'); | ||
if(isset($_POST['Login'])) | ||
{ | ||
//Make user fills out all fields | ||
if(empty($_POST['UName']) || empty($_POST['Password'])) | ||
{ | ||
header("location:../index.php?Invalid= Please Fill in the Required Fields"); | ||
} | ||
|
||
//Assuming they use all fields, log them in | ||
else | ||
{ | ||
$username = $_POST['UName']; | ||
|
||
$query = "SELECT UName FROM users WHERE UName='$username'"; | ||
$result = mysqli_query($link,$query); | ||
|
||
if(!$result){ | ||
die('Error1: ' . mysqli_error($link)); | ||
} | ||
$num = mysqli_num_rows($result); | ||
|
||
//Verify that there is only one username | ||
if($num==1){ | ||
$query2 = "SELECT firstname, lastname, UName, Password, email FROM users WHERE UName = '$username'"; | ||
$result2 = mysqli_query($link, $query2); | ||
if(!$result2){ | ||
die('Error2: ' . mysqli_error($link)); | ||
} | ||
list($first, $last, $userval, $passval, $email) = mysqli_fetch_array($result2); | ||
$password = $_POST['Password']; | ||
if(password_verify($password, $passval)){ | ||
$_SESSION['username'] = $userval; | ||
$_SESSION['firstname'] = $first; | ||
$_SESSION['lastname'] = $last; | ||
$_SESSION['email'] = $email; | ||
header("location:../pages/dashboard.php"); | ||
} | ||
} | ||
else{ | ||
header("location:../index.php?Invalid= Please Enter Correct Username or Password"); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
echo 'Not working now'; | ||
} | ||
|
||
?> |
This file was deleted.
Oops, something went wrong.
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