-
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
4 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
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,34 @@ | ||
<?php | ||
include "../config.php"; | ||
function checkUser( $username ){ | ||
global $conn; | ||
$sql = "select email from nguoidung where email = '$username'"; | ||
$result = mysqli_query( $conn, $sql ); | ||
if( mysqli_num_rows( $result ) > 0 ){ | ||
// echo "true"; | ||
return true; | ||
} | ||
// echo "false"; | ||
return false; | ||
} | ||
if( isset( $_POST['username'] ) and isset( $_POST['password'] ) ){ | ||
$check = checkUser( $_POST['username'] ); | ||
$username = $_POST['username']; | ||
$password = $_POST['password']; | ||
if( $check == true ){ | ||
header("location:index.php"); | ||
} else{ | ||
if( $password != "" ){ | ||
$password = md5( $password ); | ||
$sql = "insert into nguoidung set email = '$username', pass = '$password'"; | ||
mysqli_query( $conn, $sql ); | ||
header("location:../signup/"); | ||
} else { | ||
header("location:index.php"); | ||
} | ||
|
||
} | ||
} else { | ||
header("location:index.php"); | ||
} | ||
?> |
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,28 @@ | ||
<?php | ||
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; | ||
} else return false; | ||
} | ||
if( isset( $_POST['username'] ) and isset( $_POST['password'] ) ){ | ||
$pass = getPassword( $_POST['username'] ); | ||
if( $pass == false ){ | ||
header("location:index.php"); | ||
} else{ | ||
echo $pass; | ||
if( md5( $_POST['password'] ) == $pass ){ | ||
header("location:../index.php"); | ||
} else { | ||
header("location:index.php"); | ||
} | ||
} | ||
} | ||
|
||
?> |
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