Skip to content

Instantly share code, notes, and snippets.

@ja6z
Last active August 29, 2015 14:21
Show Gist options
  • Save ja6z/5910f0af594b9dee5316 to your computer and use it in GitHub Desktop.
Save ja6z/5910f0af594b9dee5316 to your computer and use it in GitHub Desktop.
<?php
if(isset($_SESSION['authentication'])){?>
<script type="text/javascript">
<!--
window.location = "main.php"
//-->
</script>
You're already logged in, redirecting you.
<?php }else{
if(isset($_POST['login'])){
$postedUsername = $_POST['username']; //Gets the posted username, put's it into a variable.
$postedPassword = $_POST['password']; //Gets the posted password, put's it into a variable.
$userDatabaseSelect = $m->thundergallery->users; //Selects the user collection
$userDatabaseFind = $userDatabaseSelect->find(array('username' => $postedUsername)); //Does a search for Usernames with the posted Username Variable
//Iterates through the found results
foreach($userDatabaseFind as $userFind) {
$storedUsername = $userFind['username'];
$storedPassword = $userFind['password'];
}
if($postedUsername == $storedUsername && $postedPassword == $storedPassword){
$_SESSION['authentication'] = 1;
?>
<script type="text/javascript">
<!--
window.location = "main.php"
//-->
</script> <?php
}else{
$wrongflag = 1;
}
}else{}
?>
<div class='login'>
<form action='login.php' method='post'>
<br/> You're not logged in as an admin, please do so. <br/><br/>
<?php if($wrongflag == 1){ echo "<font size='2px' color='red' face='Arial'> Wrong Username/Password </font><br/>";} ?>
<input class='login-text' type='text' name='username' value='Username' onFocus="if(this.value == 'Username') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Username';}">
<input class='login-text' type='password' name='password' value='Password' onFocus="if(this.value == 'Password') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Password';}">
<input class='login-button' type='submit' name='login' value='Login'>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment