-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.php
More file actions
107 lines (89 loc) · 2.74 KB
/
Copy pathdata.php
File metadata and controls
107 lines (89 loc) · 2.74 KB
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
<?php
require("functions.php");
$commentError = "";
$comment= "";
//kui ei ole kasutaja id'd
if (!isset($_SESSION["userId"])){
//suunan sisselogimise lehele
header("Location: login.php");
exit();
}
//kui on ?logout aadressireal siis login välja
if (isset($_GET["logout"])) {
session_destroy();
header("Location: login.php");
exit();
}
$msg="";
if(isset($session["message"])){
$msg = $_SESSION["message"];
unset($_SESSION["message"]);
}
if (isset($_POST["plate"])&&
isset($_POST["color"])&&
isset($_POST["masinatyyp"])&&
isset($_POST["comment"])&&
!empty($_POST["plate"])&&
!empty($_POST["masinatyyp"])&&
!empty($_POST["comment"])&&
!empty($_POST["color"])&&
strlen ($_POST["comment"])<255
) {
saveCar(cleanInput($_POST["plate"]), $_POST["color"], $_POST["masinatyyp"], $_POST["comment"]);
}
$masinainfo = getAllCars();
if (isset($_POST["comment"])&&
(strlen ($_POST["comment"])>255))
{
$commentError = "tekst on suurem kui lubatud";
}
?>
<h1>Data</h1>
<?=$msg;?>
<body bgcolor="#e6ffe6">
<p>
Tere tulemast <?=$_SESSION["userEmail"];?>!</a>
<a href="?logout=1">Logi välja</a>
</p>
<?php
$html = "<table style=' border: 1px solid #dddddd;
text-align: left;
padding: 8px;';>";
$html .= "<tr>";
$html .= "<th>id</th>";
$html .= "<th>numbrimärk</th>";
$html .= "<th>Masina värv</th>";
$html .= "<th>masina tüüp</th>";
$html .= "<th>kommentaar</th>";
$html .= "</tr>";
//iga liikme kohta massiivis
foreach($masinainfo as $c){
$html .= "<tr>";
$html .= "<td>".$c->id."</td>";
$html .= "<td>".$c->plate."</td>";
$html .= "<td style='background-color:".$c->color."'style='color:".$c->color."'>".$c->color."</td>";
$html .= "<td>".$c->masinatyyp."</td>";
$html .= "<td>".$c->comment."</td>";
$html .= "</tr>";
}
$html .= "</table>";
echo $html;
?>
<br> <br> <br>
<form method="POST">
Sisestage kommentaar oma pakutava masina kohta (255 char pikkus): <br>
<textarea name="comment" rows="5" cols="55" value="<?php echo $comment;?>" ></textarea><?php echo $commentError;?> <br><br>
<select name="masinatyyp" type="masinatyyp">
<option value="">...</option>
<option value="klassikaline">Klassikaline</option>
<option value="Bike">Bike</option>
<option value="mopeed">mopeed</option>
<option value="Cruiser">Cruiser</option>
<option value="Enduro">Enduro</option>
<option value="Touring">Touring</option>
</select> <br><br>
<input name="plate" placeholder = "numbri märk" type ="text" value=""><br><br>
Valige passis olev masina värv: <br>
<input type="color" name="color"><br><br>
<input type="submit" value="Sisesta">
</form>