Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <div class="boton" style="width: 100px; height: 100px;" onclick="login();">
  2. Entrar
  3. </div>
  4.  
  5. function login() {
  6. var email = document.getElementById("email").value;
  7. var password = document.getElementById("pass").value;
  8. $.ajax({
  9. url : "/sistema/backend/public/login.php",
  10. type : "POST",
  11. data : {
  12. email : email,
  13. password : password
  14. },
  15. success : function(data) {
  16. if (data === "true") {
  17. location.href = "/sistema/view/principal/index.php";
  18. } else {
  19. document.getElementById("messages").style.border = "red solid 1px";
  20. document.getElementById("messages").style.background = "#e64943";
  21. $("#messages").html(data);
  22. document.getElementById("messages").style.display = "block";
  23. }
  24. }
  25.  
  26. <?php session_start();
  27. require_once ($_SERVER['DOCUMENT_ROOT']."/sistema/backend/conection/conection.php");
  28.  
  29. if (isset($_POST["email"]) && isset($_POST["password"])) {
  30. $conn = new ConnectionDBTvsystem();
  31. $user = $conn -> getUsuario($_POST["email"], $_POST["password"]);
  32.  
  33. if (!is_null($user)) {
  34. $_SESSION['user'] = get_object_vars($user);
  35. echo "true";
  36.  
  37. } else{
  38. die("Usuario o contraseña incorrectos");
  39. }
  40.  
  41. } else {
  42. die("false");
  43. }
  44. ?>
  45.  
  46. <?php session_start();
  47. class ConnectionAdminArchivos {
  48. protected $server = "localhost";
  49. protected $user = "user";
  50. protected $passwd = "kabongo696";
  51. protected $db = "adminArchivost";
  52. protected $dbCon;
  53.  
  54. function __construct() {
  55. $this->dbCon = mysqli_connect($this->server, $this->user, $this->passwd, $this->db);
  56. $this->dbCon->set_charset("utf8");
  57. }
  58.  
  59. function __destruct() {
  60. mysqli_close($this->dbCon);
  61. }
  62.  
  63. function getUsuario($email, $pass) {
  64. $query = "SELECT * FROM usuario WHERE correo = '$email' AND password = '$pass' LIMIT 1";
  65. $result = mysqli_query($this->dbCon, $query);
  66. $object = mysqli_fetch_object($result);
  67. return $object;
  68. }
  69. }
  70. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement