-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
127 lines (110 loc) · 3.28 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<html>
<head>
<title> Autoescuela Cuela </title>
<link href="estilo.css" rel="stylesheet">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<script src="https://maps.google.com/maps?file=api&v=2&key=AIzaSyBhqZULIJ8jYl52NbhGZsUpBQWWYwEW8Dg&sensor=true_or_false" type="text/javascript"></script>
<script type="text/javascript" src="javascript/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="javascript/maps.js"></script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="cabecera">
<p>
Autoescuela Cuela
</p>
</div>
<?php
function CompruebaErrorMySQL($mensaje, $conexion){
if (mysqli_errno($conexion) != 0){
echo $mensaje.' :'.mysqli_error($conexion);
mysqli_close($conexion);
exit();
}
}
function CompruebaErrorConexionMySQL($mensaje){
if (mysqli_connect_errno() != 0){
echo $mensaje.' :'.mysqli_connect_error();
exit();
}
}
if (isset($_POST['login'])===false){
?>
<div id="tablaIndex">
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<TABLE>
<TR>
<TD>Login:</TD>
<TD>
<INPUT TYPE="text" NAME="login" SIZE="20" MAXLENGTH="30">
</TD>
</TR>
<TR>
<TD>Password:</TD>
<TD>
<INPUT TYPE="password" NAME="password" SIZE="20" MAXLENGTH="30">
</TD>
</TR>
</TABLE>
<input type="image" src="./images/autoescuela.png" id="ele" />
<!--<INPUT TYPE="submit" NAME="accede" VALUE="Accede">-->
</FORM>
<?php
}else{
$login=$_POST['login'];
$password=$_POST['password'];
$password=crypt($password,'@j@x');
try{
@ $db = mysqli_connect('127.0.0.1', 'root', 'nueva');
CompruebaErrorConexionMySQL('Error conectando con la bd');
mysqli_select_db($db, 'autoescuela');
CompruebaErrorMySQL('Error seleccionando la BD', $db);
$resultadoAlumnos = mysqli_query($db, "select * from alumnos where login='".$login."' and password='".$password."'");
$resultadoProfesores = mysqli_query($db, "select * from profesores where login='".$login."' and password='".$password."'");
CompruebaErrorMySQL('Error realizando la consulta', $db);
if (mysqli_num_rows($resultadoAlumnos) > 0 || mysqli_num_rows($resultadoProfesores) > 0){
header("Location: ./vistas/principal.html");
}else{
echo "<div id='tablaIndex'>";
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<TABLE>
<TR>
<TD>Login:</TD>
<TD>
<INPUT TYPE="text" NAME="login" SIZE="20" MAXLENGTH="30" value="<?php echo $_POST['login'] ?>">
</TD>
</TR>
<TR>
<TD>Password:</TD>
<TD>
<INPUT TYPE="password" NAME="password" SIZE="20" MAXLENGTH="30">
</TD>
</TR>
</TABLE>
<input type="image" src="./images/autoescuela.png" id="ele" />
</FORM>
</div>
<?php
mysqli_free_result($resultadoAlumnos);
mysqli_free_result($resultadoProfesores);
mysqli_close($db);
}
}catch (Exception $e){
echo $e->getMessage();
if (mysqli_connect_errno() == 0)
$db->close();
exit();
}
}
?></div>
<div id="extras">
<div id="map_canvas" style="width: 60%; height: 40%"></div>
<textarea id="textee" name="content"></textarea>
</div>
<div id="pie">
<p>
Powered by Ruben Frances
</p>
</div>
</body>
</html>