From b2b88ae5137babe80b31aba230b0b9ae46a834e3 Mon Sep 17 00:00:00 2001 From: torbghancity <50368163+torbghancity@users.noreply.github.com> Date: Mon, 30 May 2022 09:15:01 +0430 Subject: [PATCH 1/2] just add valid --- loader.php | 3 +- public/register.php | 53 +++++++++++++++++++++++++++++++++++ services/Validation/Valid.php | 20 +++++++++++++ services/layout/header.php | 4 +++ services/models/User.php | 13 +++++++-- 5 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 public/register.php create mode 100644 services/Validation/Valid.php diff --git a/loader.php b/loader.php index ae0b937..dd457d3 100644 --- a/loader.php +++ b/loader.php @@ -4,4 +4,5 @@ require(__DIR__ . "/services/db/db.php"); require(__DIR__ . "/services/layout/layout.php"); require(__DIR__ . "/services/models/loadModels.php"); -require(__DIR__ . "/services/auth/auth.php"); \ No newline at end of file +require(__DIR__ . "/services/auth/auth.php"); +require(__DIR__ . "/services/validation/valid.php"); \ No newline at end of file diff --git a/public/register.php b/public/register.php new file mode 100644 index 0000000..7fe9771 --- /dev/null +++ b/public/register.php @@ -0,0 +1,53 @@ +pass_validation($password,$password_repeat); + if ($passvalid){ + $uservalid=$valid->user_validation($username); + if(!$uservalid){ + $userData = $user->create($name,$username, $password); + if($userData){ + redirect("/login.php"); + } + else{ + echo "No .. "; + } + } + else{ + echo "نام کاربری قبلا استفاده شده...!"; + } + } + else{ + echo "رمز عبور و تکرارش برابر نیسست...!"; + } +} +Layout::pageHeader("ایجاد حساب"); +?> + +
+ + + نام: +
+
+ نام کاربری: +
+
+ رمز عبور: +
+
+ تگرار رمز عبور: +
+
+ +
\ No newline at end of file diff --git a/services/Validation/Valid.php b/services/Validation/Valid.php new file mode 100644 index 0000000..c650a56 --- /dev/null +++ b/services/Validation/Valid.php @@ -0,0 +1,20 @@ +getUserByusername($username); + return $InUser; + } +} \ No newline at end of file diff --git a/services/layout/header.php b/services/layout/header.php index 809202e..8d871ee 100644 --- a/services/layout/header.php +++ b/services/layout/header.php @@ -22,6 +22,7 @@ تماس با ما + name','$this->username','$this->password');"; + ."VALUES ('$name','$username','$password');"; $result = mysqli_query($this->dbCon, $sql); return $result; @@ -30,6 +30,7 @@ public function updateToken($userId, $token) { $sql = "UPDATE `users` set `remember_token` = '$token' where `id` = $userId"; $result = mysqli_query($this->dbCon, $sql); + } public function getUserByToken($token) @@ -39,4 +40,12 @@ public function getUserByToken($token) $result = mysqli_query($this->dbCon, $sql); return mysqli_fetch_assoc($result); } + + public function getUserByusername ($username) + { + $sql = + "SELECT * FROM `users` where `username`='$username';"; + $result = mysqli_query($this->dbCon, $sql); + return mysqli_fetch_assoc($result); + } } From b15f1eb2822a1b4d0a58d33e1b87ea465937fca9 Mon Sep 17 00:00:00 2001 From: torbghancity <50368163+torbghancity@users.noreply.github.com> Date: Sat, 18 Jun 2022 12:43:02 +0430 Subject: [PATCH 2/2] change register --- app/Controllers/AuthController.php | 35 +++++++- .../Valid.php => Validation/Valid2.php} | 16 +++- routes/web.php | 2 + views/auth/register.blade.php | 83 +++++++------------ 4 files changed, 76 insertions(+), 60 deletions(-) rename app/{Valid/Valid.php => Validation/Valid2.php} (64%) diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index 5f114c6..b317fa4 100644 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -6,6 +6,7 @@ use Services\Layout\Layout; use Services\Models\User; use Services\Validation\Valid; +use Services\Validation\Valid2; class AuthController { @@ -73,4 +74,36 @@ public function doRegister() Layout::render("auth.register", ["errorMessage"=>$errorMessage]); } -} + + public function dosignup() + { + + $donone="d-none"; + + $username = $_POST['username']; + $password =$_POST['password']; + $re_password =$_POST['re-password']; + $name = $_POST['name']; + + $valid = new Valid2(); + $error_log = $valid->check_signup($password,$re_password,$username); + + + if($error_log==""){ + $user =new User(); + + $user->username = $username; + $user->password = $password; + $user->name = $name; + + if($Userdata = $user->create()){ + redirect("/login"); + } + } + else{ + $donone = "d-block"; + } + + Layout::render("auth.register", ["errorMessage"=>$error_log]); + } +} \ No newline at end of file diff --git a/app/Valid/Valid.php b/app/Validation/Valid2.php similarity index 64% rename from app/Valid/Valid.php rename to app/Validation/Valid2.php index 51e10f7..a899672 100644 --- a/app/Valid/Valid.php +++ b/app/Validation/Valid2.php @@ -1,8 +1,8 @@ error; } + + public function empetycheck() + { + if($this->pass1 !=$this->pass2){ + $this->error = "رمزهایی عبور یکسان نیستن!"; + } + } + public function repassword() { if($this->pass1 !=$this->pass2){ - $this->error .= " پسورد ها یکسان نیستن!"; + $this->error = " پسورد ها یکسان نیستن!"; } } @@ -30,7 +38,7 @@ public function checkuser() $user_in_use = new User(); $res = $user_in_use->checkifExists($this->username); if($res>0){ - $this->error .= "
"."نام کاربری از قبل موجود است."; + $this->error = "نام کاربری از قبل موجود است."; } } diff --git a/routes/web.php b/routes/web.php index 6b212a1..4202463 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,3 +10,5 @@ $router->get("/logout", "AuthController@logout"); $router->get("/register", "AuthController@showRegisterForm"); $router->post("/doRegister", "AuthController@doRegister"); +$router->post("/dosignup", "AuthController@dosignup"); +$router->get("/contact", "ContactControllers@homecontact"); \ No newline at end of file diff --git a/views/auth/register.blade.php b/views/auth/register.blade.php index 0a12c0c..3fa7464 100644 --- a/views/auth/register.blade.php +++ b/views/auth/register.blade.php @@ -1,46 +1,20 @@ @extends("layout.app") -@section("content") - -
- {{ $errorMessage ?? ""}} -
-
- - -
- - - نام: -
-
- نام کاربری: -
-
- رمز عبور: -
-
- تگرار رمز عبور: -
-
- -
-
-@endsection +@section('Title', 'ایجاد حساب') -@section("asdad") +@section("content")
-
-
- عضویت در سایت -
-
-
- -
+
+
+ عضویت در سایت +
+
+ + +
+ name="name" placeholder="نام " >
@@ -49,30 +23,29 @@
+ required name="password" placeholder="رمز ورود " pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" + title="رمز عبور باید شامل حروف بزرگ و کوچک و عدد باشد" + onchange="check_password('floatingPassword1','alert_password')" + size="8">
+ autocomplete="off" required placeholder=" تکرار رمز ورود " pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" + onchange="check_password('floatingPassword2','alert_password2')" + size="8">
- - - - -
-
-@endsection \ No newline at end of file + + +
+ قبلا عضو شدم +
+ + + +@endsection +