-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
92 lines (54 loc) · 1.43 KB
/
data.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
<?php
require("functions.php");
//kui ei ole kasutaja id'd
if(!isset($_SESSION["userId"])){
//suunan sisselogimise lehele
header("Location: login.php");
}
if(isset($_GET["logout"])){
session_destroy();
header("Location:login.php");
}
if(isset($_POST["plate"]) && isset($_POST["color"]) &&
!empty($_POST["plate"]) && !empty($_POST["color"])
) {
savecar($_POST["plate"], $_POST["color"]);
}
$cardata=getallcars();
echo"<pre>";
var_dump($cardata);
echo"</pre>";
?>
<h1>Data</h1>
<p>
Tere tulemast <?=$_SESSION["userEmail"];?>
<a href="?logout=1">Logi valja</a>
</p>
<form method="POST">
<label>Salvesta auto</label><br><br>
<label>Auto number</label><br>
<input name="plate" type="text" placeholder="123 ABC"><br><br>
<label>Auto varv</label><br>
<input name="color" type="color">
<br><br>
<input type="submit" value="Salvesta">
</form>
<h2>Autod</h2>
<?php
$html = "<table>";
$html .= "<tr>";
$html .= "<th>id</th>";
$html .= "<th>plate</th>";
$html .= "<th>color</th>";
$html .= "</tr>";
foreach($cardata as $c) {
//echo $c->plate."<br>";
$html .= "<tr>";
$html .= "<td>".$c->id."</td>";
$html .= "<td>".$c->plate."</td>";
$html .= "<td style='color:".$c->color."'>".$c->color."</td>";
$html .= "</tr>";
}
$html .= "</table>";
echo $html;
?>