From d85d07337eabbbb236dc9394728e9d4f4d3b188d Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Date: Sat, 9 May 2015 16:04:59 +0700 Subject: [PATCH] thanhnv_58 login and signup --- login/dangky.php | 34 ++++++++++++++++++++++++++++++++++ login/index.php | 4 ++-- signup/dangnhap.php | 28 ++++++++++++++++++++++++++++ signup/index.php | 5 ++++- 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 login/dangky.php create mode 100644 signup/dangnhap.php diff --git a/login/dangky.php b/login/dangky.php new file mode 100644 index 0000000..c2f66af --- /dev/null +++ b/login/dangky.php @@ -0,0 +1,34 @@ + 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"); + } +?> \ No newline at end of file diff --git a/login/index.php b/login/index.php index e9b3f90..80fd031 100644 --- a/login/index.php +++ b/login/index.php @@ -56,7 +56,7 @@

Login to your account

-
+
@@ -74,7 +74,7 @@
diff --git a/signup/dangnhap.php b/signup/dangnhap.php new file mode 100644 index 0000000..ebaa0e7 --- /dev/null +++ b/signup/dangnhap.php @@ -0,0 +1,28 @@ + 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"); + } + } + } + +?> \ No newline at end of file diff --git a/signup/index.php b/signup/index.php index e9b3f90..de10c62 100644 --- a/signup/index.php +++ b/signup/index.php @@ -46,6 +46,9 @@ +
@@ -56,7 +59,7 @@

Login to your account

-
+