(+84) 977 141 020

HTML 5

Donec metus orci, malesuada et lectus vitae

Route::get('dang-ky','PagesController@getDangky');
    Route::post('dangky','PagesController@postDangky');
@extends('layout.index')
@section('title')
Đăng Ký
@endsection
@section('content')
<!-- Page Content -->
<main class="vertical-center">
    <div class="container">
        <div class="row">
            <div class="col-sm-offset-2 col-sm-8">
                <div class="panel panel-default register-form">
                    <div class="panel-heading">
                        <h3 class="text-center">Đăng ký tài khoản</h3>
                    </div>
                    <div class="panel-body">
                        @if (count($errors) > 0)
                        <div class="alert alert-danger">
                            @foreach ($errors->all() as $err)
                            {{$err}} <br>
                            @endforeach
                        </div>
                        @endif
                        @if (session('thongbao'))
                        <div class="alert alert-success">
                            {{session('thongbao')}}
                        </div>
                        @endif
                        <form action="dangky" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="{{ csrf_token() }}" />
                            <div class="text-center">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                    <input type="text" class="form-control" name="name" placeholder="Họ tên"
                                        aria-describedby="basic-addon1">
                                </div>
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
                                    <input type="email" class="form-control" name="email" placeholder="Email"
                                        aria-describedby="basic-addon1">
                                </div>
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                    <input type="password" class="form-control" name="password" placeholder="Mật khẩu"
                                        aria-describedby="basic-addon1">
                                </div>
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                    <input type="password" class="form-control" name="passwordAgain"
                                        placeholder="Nhập lại mật khẩu" aria-describedby="basic-addon1">
                                </div>
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="glyphicon glyphicon-picture"></i></span>
                                    <input type="file" class="form-control" name="Hinh">
                                </div>
                                <hr>
                                <input type="submit" class="btn text-center" value="ĐĂNG KÝ">
                            </div>
                        </form>
                    </div>
                    <div class="panel-footer">
                        <div class="signin">
                            <p class="text-center">Already have an account? <a href="" data-toggle="modal" data-target="#modalLoginForm"> Sign in</a>.</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!-- end Page Content -->
@endsection
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <title>Thanh Tuan | @yield('title')</title>
    <base href="{{ asset('') }}" >
    <!--Import library-->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link href="fonts/linearicons-v1.0.0/icon-font.min.css" rel="stylesheet">
    <!-- Add icon library -->
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <!-- Custom CSS -->
    @yield('css')
    <link href="css/main.css" rel="stylesheet">
    <link href="css/responsive.css" rel="stylesheet">
    <!--Add favicon-->
    <link rel="shortcut icon" href="image/favicon.png">
   
</head>
 
<body>
    
    @include('layout.header')
    @yield('content')
    @include('layout.footer')
 
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/main.js"></script>
    @yield('script')
</body>
 
</html>
function postDangky(Request $request)
    {
        $this->validate($request,[
            'name'          => 'required|min:3',
            'email'         => 'required|email|unique:users,email',
            'password'      => 'required|min:3|max:32',
            'passwordAgain' => 'required|same:password'
       ],[
            'name.required'             => 'Bạn chưa nhập tên người dùng',
            'name.min'                  => 'Tên người dùng phải có ít nhất 3 ký tự',
            'email.required'            => 'Bạn chưa nhập email',
            'email.email'               => 'Bạn chưa nhập đúng định dạng email',
            'email.unique'              => 'Email này đã đăng ký',
            'password.required'         => 'Bạn chưa nhập mật khẩu',
            'password.min'              => 'Mật khẩu phải có ít nhất 3 ký tự',
            'password.max'              => 'Mật khẩu chỉ được tối đa 32 ký tự',
            'passwordAgain.required'    => 'Bạn chưa nhập lại mật khẩu',
            'passwordAgain.same'        => 'Mật khẩu nhập lại chưa khớp'
       ]);
       $user            = new User;
       $user->name      = $request->name;
       $user->email     = $request->email;
       $user->password  = bcrypt($request->password);
       $user->quyen     = 0;
 
       if($request->hasFile('Hinh'))
       {
           $file = $request->file('Hinh');
           $duoi = $file->getClientOriginalExtension();
           if($duoi != 'jpg' && $duoi != 'png' && $duoi != 'jpeg')
           {
               return redirect('dangky')->with('loi','Bạn chỉ được chọn file có đuôi jpg,png,jpeg');
           }
           $name = $file->getClientOriginalName();
           $Hinh = str_random(4)."_".$name;
           while(file_exists("upload/users/".$Hinh))
           {
               $Hinh = str_random(4)."_".$name;
           }
           $file->move("upload/users",$Hinh);
           $user->Hinh           = $Hinh;
       }
       else
       {
           $user->Hinh           = "default.jpg";
       }
 
       $user->save();
 
        return redirect('dangky')->with('thongbao','Chúc mừng bạn đã đăng ký thành công');
    }
 $table->integer('idComment')->unsigned();
            $table->foreign('idComment')->references('id')->on('Comment')->onDelete('cascade')->onUpdate('cascade');


Bạn phải Sign in để bình luận