-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
272 additions
and
16 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,14 @@ | ||
<?php | ||
session_start(); | ||
$user = $_SESSION['user']; | ||
if (!isset($user)) { | ||
echoJson(false); | ||
} else { | ||
echoJson(true, $user); | ||
} | ||
function echoJson($status, $user = null) { | ||
header('Access-Control-Allow-Origin: *'); | ||
header('Content-Type:application/json; charset=UTF-8'); | ||
echo json_encode(["status" => $status, "user" => $user]); | ||
} | ||
?> |
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 @@ | ||
<?php | ||
session_start(); | ||
include "../../config.php"; | ||
// lay password voi username nhap vao | ||
function getPassword($username) { | ||
global $conn; | ||
$sql = "select pass from nguoidung where email = '$username'"; | ||
$result = mysqli_query($conn, $sql); | ||
|
||
if (mysqli_num_rows($result ) > 0) { | ||
$row = mysqli_fetch_array($result, MYSQL_ASSOC); | ||
$pass = $row['pass']; | ||
return $pass; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function getName($username) { | ||
global $conn; | ||
$sql = "select name from nguoidung where email = '$username'"; | ||
$result = mysqli_query($conn, $sql); | ||
|
||
if (mysqli_num_rows($result ) > 0) { | ||
$row = mysqli_fetch_array($result, MYSQL_ASSOC); | ||
$name = $row['name']; | ||
if ($name == "") { | ||
return $username; | ||
} | ||
return $name; | ||
} | ||
|
||
return "Bạn"; | ||
} | ||
|
||
function echoJson($result) { | ||
echo json_encode(array("result" => $result)); | ||
} | ||
|
||
if (isset($_POST['user']) and isset($_POST['pass'])) { | ||
$pass = getPassword($_POST['user']); | ||
if ($pass == false) { | ||
echoJson(false); | ||
} else { | ||
if (md5( $_POST['pass']) == $pass) { | ||
$_SESSION['user'] = getName($_POST['user']); | ||
echoJson(true); | ||
} else { | ||
echoJson(false); | ||
} | ||
} | ||
} | ||
else { | ||
echoJson(false); | ||
} |
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,5 @@ | ||
<?php | ||
session_start(); | ||
session_destroy(); | ||
|
||
echo "Success"; |
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,19 @@ | ||
<div class="modal fade" id="form-signin" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"> | ||
<div class="modal-dialog modal-sm"> | ||
<div class="modal-content"> | ||
<form class="form-signin" role="form"> | ||
<label for="inputEmail" class="sr-only">Email</label> | ||
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus> | ||
<label for="inputPassword" class="sr-only">Mật khẩu</label> | ||
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required> | ||
<div class="checkbox"> | ||
<label> | ||
<input type="checkbox" value="remember-me"> Nhớ tôi | ||
</label> | ||
</div> | ||
<button class="btn btn-lg btn-primary btn-block" type="button" id="btn-signin-submit">Đăng nhập</button> | ||
<span id="result-signin"></span> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
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
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