Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="boton" style="width: 100px; height: 100px;" onclick="login();">
- Entrar
- </div>
- function login() {
- var email = document.getElementById("email").value;
- var password = document.getElementById("pass").value;
- $.ajax({
- url : "/sistema/backend/public/login.php",
- type : "POST",
- data : {
- email : email,
- password : password
- },
- success : function(data) {
- if (data === "true") {
- location.href = "/sistema/view/principal/index.php";
- } else {
- document.getElementById("messages").style.border = "red solid 1px";
- document.getElementById("messages").style.background = "#e64943";
- $("#messages").html(data);
- document.getElementById("messages").style.display = "block";
- }
- }
- <?php session_start();
- require_once ($_SERVER['DOCUMENT_ROOT']."/sistema/backend/conection/conection.php");
- if (isset($_POST["email"]) && isset($_POST["password"])) {
- $conn = new ConnectionDBTvsystem();
- $user = $conn -> getUsuario($_POST["email"], $_POST["password"]);
- if (!is_null($user)) {
- $_SESSION['user'] = get_object_vars($user);
- echo "true";
- } else{
- die("Usuario o contraseña incorrectos");
- }
- } else {
- die("false");
- }
- ?>
- <?php session_start();
- class ConnectionAdminArchivos {
- protected $server = "localhost";
- protected $user = "user";
- protected $passwd = "kabongo696";
- protected $db = "adminArchivost";
- protected $dbCon;
- function __construct() {
- $this->dbCon = mysqli_connect($this->server, $this->user, $this->passwd, $this->db);
- $this->dbCon->set_charset("utf8");
- }
- function __destruct() {
- mysqli_close($this->dbCon);
- }
- function getUsuario($email, $pass) {
- $query = "SELECT * FROM usuario WHERE correo = '$email' AND password = '$pass' LIMIT 1";
- $result = mysqli_query($this->dbCon, $query);
- $object = mysqli_fetch_object($result);
- return $object;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement