Skip to content
Snippets Groups Projects
Commit 00d0c5c3 authored by Habibi's avatar Habibi
Browse files

Finish view bug

parent 8fe789d4
1 merge request!19Finish view bug
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
$rowUser = $stmtUser->fetch(); $rowUser = $stmtUser->fetch();
$username = $rowUser['username']; $username = $rowUser['username'];
$imgPath = $rowUser['img_path']; $imgPath = $rowUser['img_path'];
$review = new Review($review_id, $user_id, $book_id, $content, $rating, null, $username, $imgPath); $review = new Review($review_id, $user_id, $book_id, $content, $rating, null, $username, $imgPath);
array_push($reviews, $review); array_push($reviews, $review);
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
); );
$jwt = generateJWT($payload); $jwt = generateJWT($payload);
setcookie("Authorization", $jwt["token"], time()+APP_CONFIG["cookie_duration"],"/"); setcookie("Authorization", $jwt["token"], time()+APP_CONFIG["cookie_duration"],"/");
var_dump($_COOKIE["Authorization"]);
header('Location: /browse/'); } else { header('Location: /browse/'); } else {
writeResponse(500, "Failed register user"); writeResponse(500, "Failed register user");
} }
...@@ -104,7 +103,6 @@ ...@@ -104,7 +103,6 @@
); );
$jwt = generateJWT($payload); $jwt = generateJWT($payload);
setcookie("Authorization", $jwt["token"], time()+APP_CONFIG["jwt_duration"],"/"); setcookie("Authorization", $jwt["token"], time()+APP_CONFIG["jwt_duration"],"/");
var_dump($_COOKIE["Authorization"]);
header('Location: /browse/'); header('Location: /browse/');
} else { } else {
render('login.php',array("isError"=>true)); render('login.php',array("isError"=>true));
......
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
<title>Login</title> <title>Login</title>
<div class="container"> <div class="container">
<form class="form" action="/login/" method="POST"> <form class="form" action="/login/" method="POST" onSubmit="return validateForm()">
<h1 class="form-title">LOGIN</h1> <h1 class="form-title">LOGIN</h1>
<div class="row"> <div class="row">
<label for="username_form" class="form-label">Username</label> <label for="username_form" class="form-label">Username</label>
<input class="form-input" type="text" name="username" id="username_form"> <input class="form-input" type="text" name="username" id="username_form" required>
</div> </div>
<div class="row"> <div class="row">
<label for="password_form" class="form-label">Password</label> <label for="password_form" class="form-label">Password</label>
<input class="form-input" type="password" name="password" id="password_form"> <input class="form-input" type="password" name="password" id="password_form" required>
</div> </div>
<a class="register-link" href="/register/">Don't have an account?</a> <a class="register-link" href="/register/">Don't have an account?</a>
<br> <br>
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
</form> </form>
</div> </div>
<script src="/static/js/login.js"></script>
<?php <?php
if ($isError){ if ($isError){
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
name="content" name="content"
rows="10" rows="10"
class="review-comment" class="review-comment"
required
></textarea> ></textarea>
<input <input
type="hidden" type="hidden"
......
...@@ -4,7 +4,7 @@ body{ ...@@ -4,7 +4,7 @@ body{
.container { .container {
margin: 0 auto; margin: 0 auto;
width:30%; width:35%;
padding: 50px 15px 50px 15px; padding: 50px 15px 50px 15px;
margin-top: 100px; margin-top: 100px;
background-color: #00AFEA; background-color: #00AFEA;
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
Search Book Search Book
</h1> </h1>
</div> </div>
<form action="/results/" method="GET"> <form action="/results/" method="GET" onsubmit="return validateForm()">
<input <input
type="text" type="text"
class="search-book" class="search-book"
name="title" name="title"
placeholder="Input search terms..." placeholder="Input search terms..."
required
/> />
<div class="justify-content-end"> <div class="justify-content-end">
<button class="button-search-book" id="button-search-book"><span>Search</span></button> <button class="button-search-book" id="button-search-book"><span>Search</span></button>
......
function validateForm() {
let searchBook = document.getElementById('search_book').value;
if (!searchBook) {
return false;
}
return false;
return true;
}
\ No newline at end of file
...@@ -23,10 +23,11 @@ function enableValidateUsername(){ ...@@ -23,10 +23,11 @@ function enableValidateUsername(){
const usernameValue = username.value; const usernameValue = username.value;
const validateUsernameURL = '/api/user/validateUsername/?username='+username.value; const validateUsernameURL = '/api/user/validateUsername/?username='+username.value;
doAjax(validateUsernameURL, "GET", null, function(response){ doAjax(validateUsernameURL, "GET", null, function(response){
console.log(response);
if ((usernameValue.length<=20 && usernameValue.length>0) && !response.data){ if ((usernameValue.length<=20 && usernameValue.length>0) && !response.data){
isUsernameValid = true; isUsernameValid = true;
username.style.border = ""; username.style.border = "";
usernameCheck.style.display = "block"; usernameCheck.style.display = "inline";
}else { }else {
isUsernameValid = false; isUsernameValid = false;
username.style.border = errorStyle; username.style.border = errorStyle;
...@@ -45,7 +46,7 @@ function enableValidateEmail(){ ...@@ -45,7 +46,7 @@ function enableValidateEmail(){
if (emailValue.length>0 && !response.data && emailRegex.test(email.value) ){ if (emailValue.length>0 && !response.data && emailRegex.test(email.value) ){
isEmailValid = true; isEmailValid = true;
email.style.border = ""; email.style.border = "";
emailCheck.style.display = "block"; emailCheck.style.display = "inline";
}else { }else {
isEmailValid = false; isEmailValid = false;
email.style.border = errorStyle; email.style.border = errorStyle;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment