Skip to content

Instantly share code, notes, and snippets.

@juanchehin
Created July 5, 2023 14:10
Show Gist options
  • Save juanchehin/5308292359663e1789687343ba1ac193 to your computer and use it in GitHub Desktop.
Save juanchehin/5308292359663e1789687343ba1ac193 to your computer and use it in GitHub Desktop.
<?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