cleaner index.php code
This commit is contained in:
parent
bd9b1c8732
commit
6c755857a5
BIN
vip/file.png
BIN
vip/file.png
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 859 B |
|
@ -14,16 +14,16 @@ input[type="time"]::-webkit-calendar-picker-indicator{
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<header>
|
||||||
<h1>Pagina de usuarios frecuentes</h1>
|
<h1>Pagina de usuarios frecuentes</h1>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
if (!isset($_SESSION['user_id'])){
|
if (!isset($_SESSION['user_id'])){
|
||||||
echo '<p><a href="/parking/login/">Inicie sesión</a> para acceder a esta pagina</p>';
|
echo '<p><a href="/parking/login/">Inicie sesión</a> para acceder a esta pagina</p>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
echo "Sesion actual: ", $_SESSION['user_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $_SESSION['user_id'];
|
$id = $_SESSION['user_id'];
|
||||||
$servername = "localhost";
|
$servername = "localhost";
|
||||||
|
@ -31,6 +31,7 @@ $username = "pi2";
|
||||||
$password = "emb20";
|
$password = "emb20";
|
||||||
$database = "parking_lot";
|
$database = "parking_lot";
|
||||||
$conn = mysqli_connect($servername,$username,$password,$database);
|
$conn = mysqli_connect($servername,$username,$password,$database);
|
||||||
|
|
||||||
if(!$conn){
|
if(!$conn){
|
||||||
echo "Connection failed";
|
echo "Connection failed";
|
||||||
die("Connection failed: ". mysqli_connect_error());
|
die("Connection failed: ". mysqli_connect_error());
|
||||||
|
@ -73,7 +74,9 @@ if(sizeOf($fila_exists['place'])==0 ){
|
||||||
echo "This is something else";
|
echo "This is something else";
|
||||||
$time = $_POST['starttime'];
|
$time = $_POST['starttime'];
|
||||||
$num = $_POST['spacenum'];
|
$num = $_POST['spacenum'];
|
||||||
$reserve = $conn->query("update spaces set startTime = '$time', reserved = True where spaceID = $num");
|
$currentDate = new DateTime();
|
||||||
|
$day = $currentDate->format('Y-m-d');
|
||||||
|
$reserve = $conn->query("update spaces set date = '$day', startTime = '$time', reserved = True where spaceID = $num");
|
||||||
$reserve = $conn->query("update users set time = '$time', place = $num where id = $id");
|
$reserve = $conn->query("update users set time = '$time', place = $num where id = $id");
|
||||||
header("Location:/parking/vip/");
|
header("Location:/parking/vip/");
|
||||||
}
|
}
|
||||||
|
@ -88,20 +91,24 @@ if (sizeOf($fila['spaceID']) != 0){
|
||||||
<p>Utiliza este codigo QR para validar tu reservación al entrar al estacionamiento</p>';
|
<p>Utiliza este codigo QR para validar tu reservación al entrar al estacionamiento</p>';
|
||||||
|
|
||||||
$url = "'http://192.168.1.130/parking/vip/validate.php?number=$selected&userid=$id&secret=$code'";
|
$url = "'http://192.168.1.130/parking/vip/validate.php?number=$selected&userid=$id&secret=$code'";
|
||||||
exec('sudo qrencode -s 30 -o file.png '. $url);
|
exec('sudo qrencode -s 20 -o file.png '. $url);
|
||||||
echo '<img src="file.png">';
|
echo '<img src="file.png">';
|
||||||
if($_POST['freenum'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
if($_POST['freenum'] and $_SERVER['REQUEST_METHOD'] == "POST"){
|
||||||
$cancelled = $_POST['freenum'];
|
$cancelled = $_POST['freenum'];
|
||||||
//if (sizeOf($fila['spaceID']) != 0){
|
$free_place = $conn->query("update spaces set reserved = 0, startTime = NULL, endTime = NULL where spaceID = $cancelled");
|
||||||
$request = $conn->query("update spaces set reserved = 0, startTime = NULL, endTime = NULL where spaceID = $cancelled");
|
$free_place = $conn->query("update users set place = NULL, time = NULL where id = '$id'");
|
||||||
$request = $conn->query("update users set place = NULL, time = NULL where id = '$id'");
|
|
||||||
mysqli_close($conn);
|
mysqli_close($conn);
|
||||||
header("Location:/parking/vip/");
|
header("Location:/parking/vip/");
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqli_close($conn);
|
mysqli_close($conn);
|
||||||
?>
|
?>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>Todos los derechos reservados (©).</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue