forked from VictorGaribay/CRUD-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidar.php
51 lines (35 loc) · 1.15 KB
/
validar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
//include("connect_db.php");
//$miconexion = new connect_db;
session_start();
require("config/connect.php");
$username=$_POST['user'];
$pass=$_POST['password'];
//la variable $mysqli viene de connect_db que lo traigo con el require("connect_db.php");
/* $sql2=mysqli_query($mysqli,"SELECT * FROM login WHERE user='$username'");
if($f2=mysqli_fetch_assoc($sql2)){
if($pass==$f2['pasadmin']){
$_SESSION['id']=$f2['id'];
$_SESSION['user']=$f2['user'];
$_SESSION['rol']=$f2['rol'];
echo '<script>alert("BIENVENIDO ADMINISTRADOR")</script> ';
echo "<script>location.href='admin.php'</script>";
}
}
*/
$sql=mysqli_query($mysqli,"SELECT * FROM login WHERE user = '$username'");
if($f=mysqli_fetch_assoc($sql)){
if($pass==$f['password']){
$_SESSION['id']=$f['id'];
$_SESSION['user']=$f['user'];
// $_SESSION['rol']=$f['rol'];
header("Location: index.php");
}else{
echo '<script>alert("CONTRASEÑA INCORRECTA")</script> ';
echo "<script>location.href='perfil.php'</script>";
}
}else{
echo '<script>alert("ESTE USUARIO NO EXISTE")</script> ';
echo "<script>location.href='perfil.php'</script>";
}
?>