Created
July 5, 2023 14:10
-
-
Save juanchehin/5308292359663e1789687343ba1ac193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ($_SERVER['REQUEST_METHOD'] != 'POST') { | |
echo' | |
<div class="row"> | |
<div class="small-12 columns"> | |
<form method="post" action=""> | |
<fieldset class="panel"> | |
<center> | |
<h1>Sign In</h1><br> | |
</center> | |
<label> | |
<input type="text" id="username" name="username" | |
placeholder="Username"> | |
</label> | |
<label> | |
<input type="password" id="password" name="password" | |
placeholder="Password"> | |
</label> | |
<center> | |
<input type="submit" class="button" value="Sign In"> | |
</center> | |
</fieldset> | |
</form> | |
</div> | |
</div>'; | |
} else { | |
// the user has already filled out the login form. | |
// pull in database info from config.php | |
$servername = getenv('IP'); | |
$username = $mysqlUsername; | |
$password = $mysqlPassword; | |
$database = $mysqlDB; | |
$dbport = $mysqlPort; | |
$database = new mysqli($servername, $username, $password, $database,$dbport); | |
if ($database->connect_error) { | |
echo "ERROR: Failed to connect to MySQL"; | |
die; | |
} | |
$sql = "SELECT userId, username, admin, moderator FROM users WHERE username = | |
'".$_POST['username']."' AND password = '".sha1($_POST['password'])."';"; | |
$result = mysqli_query($database, $sql); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment