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 +