Advertisement
Guest User

checklogin.php

a guest
Dec 18th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'DB_login.php';
  4. require_once 'UTILS.php';
  5.  
  6. session_start();
  7.  
  8. $idcheck = $_POST["username"];
  9. $idpassword = $_POST["password"];
  10.  
  11. //Create connection to database
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13.  
  14. // Check connection
  15. if ($conn->connect_error) {
  16.     die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19. $sql = "SELECT username
  20.        FROM users WHERE username='$idcheck' and password = '$idpassword'";
  21. $result = $conn->query($sql);
  22.  
  23. //checkErrorReturn is a simple error-reporting and link-offering
  24. //function written in UTILS.php
  25. //Generally, you should put such auxliary functions in separte
  26. //files which can be imported from several scripts
  27. checkErrorReturn
  28.     ($result->num_rows == 0,
  29.      
  30.      "This username does not exist.",
  31.      "Back to the signin page",
  32.      "index.html");
  33.  
  34. //$row = $result->fetch_assoc();
  35.  
  36. //Store the alienname in the session array, to make it available
  37. //to the next page, namely alienPicturesPage
  38. $_SESSION['username'] = $idcheck;
  39.  
  40. //Instruct client to switch to a new location:
  41. header ("Location: UserHomePage2.php");
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement