Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function loginCheck($conn){
- session_start();
- //Check if login is achieved
- //Get variables from form
- $username=$_POST['namebox'];
- $password=$_POST['passbox'];
- $id=$_POST['idbox'];
- $stmt= $conn->prepare("SELECT * FROM users WHERE username =:username AND password=:password AND id=:id");
- $stmt->bindParam(':username',$username);
- $stmt->bindParam(':password',$password);
- $stmt->bindParam(':id',$id);
- $stmt->execute();
- if(($stmt->rowCount()>0) ||($_SESSION['admin'])){
- echo "<p>Login successful</p>";
- $_SESSION['admin']=true;
- if ($id = 1 && $id =2) {
- header('Location: home.php');
- }
- else if ($id = 3) {
- header('Location: home.1.php');
- }
- else if ($id = 4) {
- header('Location: home.2.php');
- }
- else if ($id > 5) {
- header('Location: home.2.php');
- }
- return true;
- }
- else {
- return false;
- }
- }//End of loginCheck
- function loginCheck($conn){
- session_start();
- //Check if login is achieved
- //Get variables from form
- $username=$_POST['namebox'];
- $password=$_POST['passbox'];
- $age=$_POST['agebox'];
- $stmt= $conn->prepare("SELECT * FROM users WHERE username =:username AND password=:password AND age=:age");
- $stmt->bindParam(':username',$username);
- $stmt->bindParam(':password',$password);
- $stmt->bindParam(':age',$age);
- $stmt->execute();
- if(($stmt->rowCount()>0) ||($_SESSION['admin'])){
- echo "<p>Login successful</p>";
- $_SESSION['admin']=true;
- if ($age > 16) {
- header('Location: home.php');
- }
- else if ($age >11 && $age <15) {
- header('Location: home.1.php');
- }
- else if ($age >6 && $age <10) {
- header('Location: home.2.php');
- }
- else if ($age >2 && $age <5) {
- header('Location: home.3.php');
- }
- return true;
- }
- else {
- return false;
- }
- }//End of loginCheck
- <?php
- require('functions.php');
- if(loginCheck($conn)){
- header('Location: home.php');
- }
- else {
- require('loginheader.php');
- ?>
- <form name="login" action="" method="POST">
- <label style="color: white; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" required><u>Name</u> : </label>
- <input type="text" name="namebox" length="20">
- <br/><br/>
- <label style="color: white; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" required><u>Password</u> : </label>
- <input type="password" name="passbox" length="20">
- <br/><br/>
- <label style="color: white; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;" required><u>ID</u> : </label>
- <input type="number" name="idbox" length="20">
- <br/><br/>
- <input type="submit" class="button" name="submit">
- </form>
- <?php
- require('footer.php');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement