Login works

This commit is contained in:
amazing-username
2017-05-24 21:21:45 -05:00
parent 577b494ecc
commit 6fb825de5c
7 changed files with 150 additions and 19 deletions
+56 -4
View File
@@ -3,21 +3,73 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class HomeController extends Controller
{
//
public function index()
{
//return "HomeIsWhereTheMoneyIs";
return view('home');
}
public function login()
{
return view('login');
return view('login', ['message' => '']);
}
public function register()
{
return view('register');
return view('register', ['message' => '']);
}
public function registerUser(Request $stuff)
{
$firstname = $stuff->input('firstname');
$lastname = $stuff->input('lastname');
$username = $stuff->input('username');
$password = $stuff->input('password');
$confirm = $stuff->input('confirm');
$emptfirstname = isset($firstname);
$emptlastname = isset($lastname);
$emptusername = isset($username);
$emptpassword = isset($password);
$emptconfirm = isset($confirm);
if (!$emptfirstname | !$emptlastname | !$emptusername | !$emptpassword | !$confirm)
{
return view('register', ['message' => 'Remember to fill in all the fields']);
}
if ($password!==$confirm)
{
return view('register', ['message' => 'Password and confirm must be the same']);
}
DB::table('users')->insert(
['firstname' => $firstname, 'lastname' => $lastname, 'username' => $username, 'password' => $password]
);
return view('created', ['username' => $username]);
}
public function loginUser(Request $stuff)
{
$username = $stuff->input('username');
$password = $stuff->input('password');
$emptusername = isset($username);
$emptpassword = isset($password);
if (!$emptusername | !$emptpassword)
{
return view('login', ['message' => 'Don\'t forget to enter both fields...']);
}
$user = DB::table('users')->where('username', $username)->first();
$pass = DB::table('users')->where('password', $password)->first();
$emptuser = isset($user);
$emptpass = isset($pass);
if (!$emptuser | !$emptpass)
{
return view('login', ['message' => 'No account found that matches']);
}
else
{
return view('userhome', ['username' => $username]);
}
}
}
+20
View File
@@ -0,0 +1,20 @@
<html>
<head>
<title>HomeIsWhereTheMoneyIs</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body style="background-color:#eee">
<div class="jumbotron text-center">
<h1>Alright {{ $username }}, your account has been created</h1>
<a href="/"><h1>Home</h1></a>
</div>
</body>
</html>
+3 -3
View File
@@ -11,11 +11,11 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<body style="background-color:#eee">
<div class="jumbotron text-center">
<h1>HomeIsWhereTheMoneyIs</h1>
<a href="login"><button style="height:40%;width:40%"><h1 style="font-size:1000%">Login</h1></button><br></a>
<a href="register"><button style="height:20%;width:20%"><h1 style="font-size:500%">Register</h1></button></a>
<a href="login"><button style="height:40%;width:90%"><h1 style="font-size:1000%">Login</h1></button><br></a>
<a href="register"><button style="height:20%;width:50%"><h1 style="font-size:500%">Register</h1></button></a>
</div>
</body>
</html>
+18 -7
View File
@@ -11,14 +11,25 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<body style="background-color:#eee">
<div class="jumbotron text-center">
<h1>Login Page</h1>
<a href="/">Home</a>
<!--
<a href="stunt"><button style="height:40%;width:40%"><h1 style="font-size:1000%">Login</h1></button><br></a>
<button style="height:20%;width:20%"><h1 style="font-size:500%">Register</h1></button>
-->
</div>
<a href="/"><h1>Home</h1></a>
{{ Form::open(array('action' => 'HomeController@loginUser')) }}
<p>
{{ Form::label("username") }}
{{ Form::text("username") }}
</p>
<p>
{{ Form::label("password") }}
{{ Form::password("password") }}
</p>
<p>
{{ Form::submit("Login maxipad resident") }}
</p>
{{ Form::close() }}
<h1>{{ $message }}</h1>
</div>
</body>
</html>
+28 -2
View File
@@ -11,14 +11,40 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<body style="background-color:#eee">
<div class="jumbotron text-center">
<h1>Registration Page</h1>
<a href="/">Home</a>
<a href="/"><h1>Home</h1></a>
<!--
<a href="stunt"><button style="height:40%;width:40%"><h1 style="font-size:1000%">Login</h1></button><br></a>
<button style="height:20%;width:20%"><h1 style="font-size:500%">Register</h1></button>
-->
{{ Form::open(array('action' => 'HomeController@registerUser', 'method' => 'post')) }}
<p>
{{ Form::label('first name') }}
{{ Form::text('firstname') }}
</p>
<p>
{{ Form::label('last name') }}
{{ Form::text('lastname') }}
</p>
<p>
{{ Form::label('username') }}
{{ Form::text('username') }}
</p>
<p>
{{ Form::label('password') }}
{{ Form::password('password') }}
</p>
<p>
{{ Form::label('confirm') }}
{{ Form::password('confirm') }}
</p>
<p>
{{ Form::submit('register me') }}
</p>
{{ Form::close() }}
<h1>{{ $message }}</h1>
</div>
</body>
</html>
+23
View File
@@ -0,0 +1,23 @@
<html>
<head>
<title>HomeIsWhereTheMoneyIs</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body style="background-color:#eee">
<div class="jumbotron text-center">
<h1>What's good {{$username}}? it's your home page</h1>
<br>
<a href=""><button style="height:30%;width:70%"><h1>Create Bill</h1></button><br></a>
<a href=""><button style="height:30%;width:70%"><h1>Manage Bills</h1></button><br></a>
<a href=""><button style="height:30%;width:70%"><h1>View Bills</h1></button><br></a>
</div>
</body>
</html>
+2 -3
View File
@@ -13,6 +13,8 @@
Route::get('/', 'HomeController@index');
Route::get('login', 'HomeController@login');
Route::get('register', 'HomeController@register');
Route::post('register/post', 'HomeController@registerUser');
Route::post('login/post', 'HomeController@loginUser');
Route::get('laravel', function () {
return view('welcome');
});
@@ -30,8 +32,5 @@ Route::get('stunt', function () {
user->save();
*/
return "Check the database, I think someone was created";
});
//Route::resource('user', 'UserController');
//Route::get('user/index', 'App\Http\Controllers\UserController@index');