Skip to content

Commit

Permalink
added more validations in manage profile
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGuy007 committed Mar 31, 2022
1 parent dd6c08a commit 8cd2991
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
15 changes: 14 additions & 1 deletion classes/ProfileContr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,25 @@ public function updateUserAccount() {
header("location: ../manage_profile.php?error=passwords_dont_match");
exit();
}
else if ($this->emptyInput($this->username, $this->pwd, $this->repeatPwd, $this->email))

if ($this->emptyInput($this->username, $this->pwd, $this->repeatPwd, $this->email))
{
header("location: ../manage_profile.php?error=empty_input");
exit();
}

if ($this->invalidUid($this->username))
{
header("location: ../manage_profile.php?error=invalid_uid");
exit();
}

if (!$this->uidExists($this->username, $this->email))
{
header("location: ../manage_profile.php?error=invalid_uid");
exit();
}

$this->setUserAccount($this->username, $this->pwd, $this->email, $this->memberID);

header("location: ../manage_profile.php?error=none");
Expand Down
17 changes: 7 additions & 10 deletions manage_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="card rounded-card black" style="width: 650px; ">
<div class="row">
<button id="edit" style="text-align:left" class="btn orange " onclick="confirm_edit(this)" style="margin-right: 20px">Edit</button>
<div class="errormsg bold"><p id="msg"></p></div>
<div class="errormsg bold"><p id="msg" class="red-text"></p></div>

<div class="errormsg">
<?php
Expand All @@ -25,24 +25,21 @@
if ($_GET["error"] == "empty_input")
echo "<script>document.getElementById('msg').innerHTML = '*Fill in all fields!';</script>";

else if ($_GET["error"] == "invalid_uid")
if ($_GET["error"] == "invalid_uid")
echo "<script>document.getElementById('msg').innerHTML = '*Choose a proper username!';</script>";

else if ($_GET["error"] == "invalidemail")
echo "<script>document.getElementById('msg').innerHTML = '*Choose a proper email!';</script>";

else if ($_GET["error"] == "passwords_dont_match")
if ($_GET["error"] == "passwords_dont_match")
echo "<script>document.getElementById('msg').innerHTML = '*Passwords doesn't match!';</script>";

else if ($_GET["error"] == "stmtfailed")
if ($_GET["error"] == "stmtfailed")
echo "<script>document.getElementById('msg').innerHTML = '*Something went wrong, please try again!';</script>";

else if ($_GET["error"] == "username_taken")
if ($_GET["error"] == "username_taken")
echo "<script>document.getElementById('msg').innerHTML = '*Username already taken!';</script>";

else if ($_GET["error"] == "none")
if ($_GET["error"] == "none")
echo "<script>document.getElementById('msg').className = 'green-text';</script>";
echo "<script>document.getElementById('msg').innerHTML = 'Profile updated!';</script>";
echo "<script>document.getElementById('msg').style.color = 'green';</script>";
}

?>
Expand Down

0 comments on commit 8cd2991

Please sign in to comment.