Skip to content

Commit

Permalink
fixed text input not sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGuy007 committed Feb 19, 2022
1 parent 7864b85 commit f9724fe
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 70 deletions.
2 changes: 1 addition & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
</div>
<div class="card-action">
<a href="#">Learn More</a>
<a href="admin_manage_users.php">Learn More</a>
</div>
</div>
</div>
Expand Down
33 changes: 24 additions & 9 deletions admin_manage_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<form id="search_user" action="admin_manage_users.php" method="POST">
<div class="row" style="margin: 0px;">
<div class="input-field col s3" style = "color:azure">
<input name="search_member" type="text" class="validate white-text" maxlength="20">
<input name="search_member" id="search_member" type="text" class="validate white-text" maxlength="20">
<label for="search_member">Search member by name</label>
<div class="errormsg">
<?php
Expand Down Expand Up @@ -87,27 +87,27 @@
<div class="card rounded-card">
<div class="card-content">
<span class="card-title orange-text bold">Create User</span>
<form action="#" method="POST">
<form id="create">
<div class="row">
<div class="input-field col s8 white-text">
<i class="material-icons prefix">account_circle</i>
<input name="username" type="text" class="validate white-text" minlength="5" maxlength="12">
<input name="username" id="username" type="text" class="validate white-text" minlength="5" maxlength="12">
<span class="helper-text grey-text" data-error="Min 5, Max 12 characters" data-success="Min 5, Max 12 characters">Min 5, Max 12 characters</span>
<label for="username" class="white-text"> Username</label>
</div>
</div>
<div class="row">
<div class="input-field col s8 white-text">
<i class="material-icons prefix"> password</i>
<input name="pwd" type="password" class="validate white-text" minlength="8" maxlength="20">
<input name="pwd" id="pwd" type="password" class="validate white-text" minlength="8" maxlength="20">
<span class="helper-text grey-text" data-error="Min 8, Max 20 characters" data-success="Min 8, Max 20 characters">Min 8, Max 20 characters</span>
<label for="pwd" class="white-text"> Password</label>
</div>
</div>
<div class="row">
<div class="input-field col s8 white-text">
<i class="material-icons prefix"> password</i>
<input name="repeat_pwd" type="password" class="validate white-text" maxlength="14">
<input name="repeat_pwd" id="repeat_pwd" type="password" class="validate white-text" maxlength="14">
<label for="repeat_pwd" class="white-text"> Repeat Password</label>
</div>
</div>
Expand All @@ -125,10 +125,10 @@
<div class="row">
<div class="input-field col s8 white-text">
<i class="material-icons prefix">email</i>
<input name="email" type="email" class="validate white-text" maxlength="25">
<input name="email" id="email" type="email" class="validate white-text" maxlength="25">
<label for="email" class="white-text">Email</label>
<span class="helper-text white-text" data-error="wrong" data-success="correct"></span>
<div class="errormsg">
<div id="message" class="errormsg">
<?php
if (isset($_GET["error"]))
{
Expand All @@ -151,8 +151,7 @@
</div>
</div>
</div>
<input class="btn orange btn-block z-depth-5" type="submit" name="submit_user" value="Create User" onsubmit="return false;">
<?php $oper->setUser(); ?>
<input class="btn orange btn-block z-depth-5" type="submit" name="submit_user" id="submit_btn" value="Create User">
</form>
</div>
</div>
Expand All @@ -163,6 +162,22 @@
<script>
$(document).ready(function(){
$('select').formSelect();

$("#submit_btn").click(function(){
var formData = new FormData($(form)[0]);
$.ajax({
url: "includes/admin.inc.php",
method: "POST",
data: formData,
processData: false,
contentType: false,

success: function(data) {
$('form').trigger("reset");
}
});
return false;
});
});
</script>

Expand Down
39 changes: 0 additions & 39 deletions classes/admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,43 +78,4 @@ protected function inspectUser(){
);
}
}

protected function createUser(){
if (isset($_POST["submit_user"]))
{
$username = $_POST["username"];
$pass = $_POST["pwd"];
$repeatPass = $_POST["repeat_pwd"];
$email = $_POST["email"];
$privilegeLevel = $_POST["level"];

$util = new CommonUtil;

if (EmptyInputCreateUser($username, $pass, $repeatPass, $email, $privilegeLevel))
{
echo("<script>location.href = 'admin_manage_users.php?error=empty_input';</script>");
exit();
}
if ($util->pwdNotMatch($pass, $repeatPass))
{
echo("<script>location.href = 'admin_manage_users.php?error=passwords_dont_match';</script>");
exit();
}
if ($util->invalidUid($username))
{
echo("<script>location.href = 'admin_manage_users.php?error=invalid_uid';</script>");
exit();
}
if ($util->uidExists($username, $email))
{
echo("<script>location.href = 'admin_manage_users.php?error=username_taken';</script>");
exit();
}

$privilegeLevel -= 1;
$util->setUser($username, $pass, $email, $privilegeLevel);
echo("<script>location.href = 'admin_manage_users.php?error=none';</script>");
$this->conn()->close();
}
}
}
4 changes: 0 additions & 4 deletions classes/adminContr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ public function usersList(){
public function showInspectedUser(){
$this->inspectUser();
}

public function setUser(){
$this->createUser();
}
}
3 changes: 2 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script src="./static/materialize/js/materialize.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="./static/materialize/js/materialize.min.js"></script>
<link rel="stylesheet" href="./static/css/base.css">
</head>

Expand Down
38 changes: 38 additions & 0 deletions includes/admin.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

if (isset($_POST["username"]))
{
$username = $_POST["username"];
$pass = $_POST["pwd"];
$repeatPass = $_POST["repeat_pwd"];
$email = $_POST["email"];
$privilegeLevel = $_POST["level"];

$util = new CommonUtil;

if (EmptyInputCreateUser($username, $pass, $repeatPass, $email, $privilegeLevel))
{
echo("<script>location.href = 'admin_manage_users.php?error=empty_input';</script>");
exit();
}
if ($util->pwdNotMatch($pass, $repeatPass))
{
echo("<script>location.href = 'admin_manage_users.php?error=passwords_dont_match';</script>");
exit();
}
if ($util->invalidUid($username))
{
echo("<script>location.href = 'admin_manage_users.php?error=invalid_uid';</script>");
exit();
}
if ($util->uidExists($username, $email))
{
echo("<script>location.href = 'admin_manage_users.php?error=username_taken';</script>");
exit();
}

$privilegeLevel -= 1;
$util->setUser($username, $pass, $email, $privilegeLevel);
echo("<script>location.href = 'admin_manage_users.php?error=none';</script>");
$this->conn()->close();
}
10 changes: 5 additions & 5 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text">account_circle</i>
<label class="white-text">Username or Email</label>
<input type="text" name="username" class="white-text">
<label class="white-text" for="username">Username or Email</label>
<input type="text" name="username" id="username" class="white-text">
</div>
</div>
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text">password</i>
<label class="white-text">Password</label>
<input type="password" name="pwd" class="white-text">
<label class="white-text" for="pwd">Password</label>
<input type="password" name="pwd" id="pwd" class="white-text">
</div>
</div>
<div class="row">
<button type="submit" name="submit" class="btn" style="margin-left: 50px">Login</button>
<button type="submit" name="submit" class="btn" style="margin-left: 10px">Login</button>
</div>
<div class="row">
<a href="recover_pass.php" style="margin-right: 10px">Forgot Password?</a>
Expand Down
10 changes: 5 additions & 5 deletions manage_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<i class="material-icons prefix">account_circle</i>
<?php
echo "<input disabled name='id' type='hidden' value='$memberID'/>";
echo"<input disabled class='validate white-text' minlength='5' maxlength='12' name='username' type='text' value='$username'/>";
echo"<input disabled class='validate white-text' minlength='5' maxlength='12' name='username' id='username' type='text' value='$username'/>";
?>
<label class='cyan-text' for="username">Enter New Username</label>
<span class="helper-text grey-text" data-error="Min 5, Max 12 characters" data-success="Min 5, Max 12 characters">Min 5, Max 12 characters</span>
Expand All @@ -65,7 +65,7 @@
<div class="input-field s6">
<i class="material-icons prefix">email</i>
<?php
echo "<input disabled class='white-text validate' name='email' type='email' value='$email'/>";
echo "<input disabled class='white-text validate' name='email' id='email' type='email' value='$email'/>";
?>
<label class='cyan-text' for="email">Enter New Email</label>
<span class="helper-text white-text" data-error="wrong" data-success="correct"></span>
Expand All @@ -74,15 +74,15 @@
<div class="row">
<div class="input-field s6">
<i class="material-icons prefix"> password</i>
<input disabled class='white-text validate' name="pwd" type="password" minlength="8" maxlength="20">
<label class='cyan-text' for="password">Enter New Password</label>
<input disabled class='white-text validate' name="pwd" id="pwd" type="password" minlength="8" maxlength="20">
<label class='cyan-text' for="pwd">Enter New Password</label>
<span class="helper-text grey-text" data-error="Min 8, Max 20 characters" data-success="Min 8, Max 20 characters">Min 8, Max 20 characters</span>
</div>
</div>
<div class="row">
<div class="input-field s6">
<i class="material-icons prefix"> password</i>
<input disabled class='white-text validate' name="repeat_pwd" type="password" maxlength="20">
<input disabled class='white-text validate' name="repeat_pwd" id="repeat_pwd" type="password" maxlength="20">
<label class='cyan-text' for="repeat_pwd"> Repeat New Password</label>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text">account_circle</i>
<input name="username" type="text" class="validate white-text" minlength="5" maxlength="12">
<input name="username" id="username" type="text" class="validate white-text" minlength="5" maxlength="12">
<label for="username" class="white-text">Username</label>
<span class="helper-text grey-text left-align" data-error="Min 5, Max 12 characters" data-success="Min 5, Max 12 characters">Min 5, Max 12 characters</span>
</div>
</div>
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text"> password</i>
<input name="pwd" type="password" class="validate white-text" minlength="8" maxlength="20">
<label for="password" class="white-text"> Password</label>
<input name="pwd" id="pwd" type="password" class="validate white-text" minlength="8" maxlength="20">
<label for="pwd" class="white-text"> Password</label>
<span class="helper-text grey-text left-align" data-error="Min 8, Max 20 characters" data-success="Min 8, Max 20 characters">Min 8, Max 20 characters</span>
</div>
</div>
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text"> password</i>
<input name="repeat_pwd" type="password" class="validate white-text" maxlength="20">
<input name="repeat_pwd" id="repeat_pwd" type="password" class="validate white-text" maxlength="20">
<label for="repeat_pwd" class="white-text"> Repeat Password</label>
</div>
</div>
<div class="row">
<div class="input-field col s4 offset-s4">
<i class="material-icons prefix white-text">email</i>
<input name="email" type="email" class="validate white-text" maxlength="25">
<input name="email" id="email" type="email" class="validate white-text" maxlength="25">
<label for="email" class="white-text">Email</label>
<span class="helper-text white-text" data-error="wrong" data-success="correct"></span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion static/css/base.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url(../materialize/css/materialize.css);
@import url(../materialize/css/materialize.min.css);
@import url(searchBar.css);
@import url(nav.css);
@import url(cards.css);
Expand Down

0 comments on commit f9724fe

Please sign in to comment.