This code is supposed to reveal three buttons: modify items, add items, and view accounts, which should only be shown once proper credentials for username and password (hardcoded username = frankbutt and password=franbuttpower123) are shown.
Code:
<?php
$show = False;
if(strcmp($_POST["username"], "FrankButt") ==0){
if(strcmp($_POST["password"], "frantbuttpower123") ==0){
$show = True;
}
}
?>
<html>
<link rel="stylesheet" href="../style/admin.css">
<link rel="stylesheet" href="../style/form.css">
<h1 class="adminHeader">Admin Access</h1>
<br>
<br>
<br>
<form action="adminLogin.php" method="post" class="formBox">
<input type="text" name="username" class="loginFill" placeholder="Username"><br>
<input type="password" name="password" class="loginFill" placeholder="Password"><br>
<button type="submit" class="adminsubmitsignin">Sign In</button>
</form>
if(<?php echo $show; ?>){
<button class= "adminOptions" onClick="selectItem.php">Modify Items</button>
<br>
<button class="adminOptions" onClick="adminImageUpload.php">Add Items</button>
<br>
<button class="adminOptions" onClick="adminHome.php">View Accounts</button>
<br>
}
</html>
I tried to approach the problem by making a boolean that becomes true if the username and password entries are equal to the hardcoded values given. I then wanted to use that boolean for the html code to behave a certain way
ifis inside the HTML, which doesn't know anything about if statements. Move the PHP tags to surround the full if statement and opening brace, and add another set to surround the closing brace