-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidate_A.php
40 lines (32 loc) · 928 Bytes
/
Validate_A.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
<?php
$connect = mysqli_connect("localhost", "root", "", "dreambucks");
// aqui se valida al admi que quiera hacer login
$ID= test_input($_POST['id']);
$PASSWORD= test_input($_POST['password']);
// una funcion para limpiar y evitar inyecciones
function test_input($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
// validar id y password
$consult="SELECT*
FROM admins
WHERE id_A='$ID' and password_A='$PASSWORD' ";
$result = mysqli_query($connect, $consult);
$rows= mysqli_num_rows($result);
if($rows){
session_start();
$_SESSION["id_A"] = $_POST["id"];
header("location:admin.php");
}else{
echo "<script>
alert('Usuario o Password incorrecto');
window.location =Login_A.php;
</script>";
header("location:fakeDataA.html");
}
mysqli_free_result($result);
mysqli_close($connect);
?>