Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. $root = "../";
  3. include $root."includes/php/initial.php";
  4. include $root."includes/php/classUtama.php";
  5.  
  6. //DATABASE CONNECTION
  7. $db = new classUtama(ADMIN_SESSION_NAME);
  8. $db->mysql_connect(true);
  9.  
  10. $_message = array();
  11.  
  12. if(strlen($_POST["username"])==0) {
  13. $_message[count($_message)] = "Name needed!";
  14. }
  15.  
  16. if(strlen($_POST["password"])==0) {
  17. $_message[count($_message)] = "Password Needed!";
  18. }
  19.  
  20. if(strlen($_POST["username"])>0 && strlen($_POST["password"])>0) {
  21. $data_login = $db->getFieldValue("admin_users", array("id", "nama", "email", "userid", "password", "'ADMIN' AS tipe_user"), array("userid" => $_POST["username"], "password" => $db->acakpassword($_POST["password"])));
  22. if($data_login[0]["userid"]==$_POST["username"] && $data_login[0]["password"]==$db->acakpassword($_POST["password"])) {
  23. unset($data_login[0]["password"]);
  24. } else {
  25. $_message[count($_message)] = "Login not valid!";
  26. }
  27. }
  28.  
  29. if(count($_message)==0) {
  30. $_SESSION[ADMIN_SESSION_NAME] = array("is_login" => true, "user" => $data_login[0]);
  31. } else {
  32. unset($_SESSION[ADMIN_SESSION_NAME]);
  33. $_SESSION['loginusers'] = array("error" => $_message, "field" => $_POST);
  34. }
  35. $db->mysql_close();
  36.  
  37. header("location: ".ADMINWEB_URL."/index.php");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement