Show sourcecode
The following files exists in this folder. Click to view.
exercise/
hi.php
include_1.php
include_2a.php
include_2b.php
include_2c.php
include_lib.php
index.php
ovn_cookie-session1.php
ovn_cookie-session2.php
ovn_cookie-session3.php
ovn_cookie-session3a.php
ovn_cookie-session4.php
ovn_form1.php
ovn_form1a.php
ovn_form2.php
ovn_form2a.php
ovn_form3.php
ovn_form3a.php
ovn_form4.php
ovn_form4a.php
ovn_form5.php
ovn_form5a.php
ovn_form6.php
ovn_form6a.php
ovn_form7.php
ovn_form7a.php
ovn_ft1.php
ovn_ft1a.php
ovn_ft2.php
ovn_ft3.php
ovn_ft4.php
ovn_ft5.php
ovn_ft6.php
ovn_funk1.php
ovn_funk2.php
ovn_funk3.php
ovn_funk4.php
ovn_funk5.php
ovn_funk6.php
ovn_funk7.php
ovn_funk8.php
ovn_funk9.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3.php
ovn_gr4.php
ovn_gr5.php
ovn_gr6.php
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass4.php
ovn_klass5.php
ovn_klass6.php
ovn_klass7.php
ovn_ms1.php
ovn_ms1a.php
ovn_ms1b.php
ovn_ms1c.php
ovn_ms2.php
ovn_ms2a.php
ovn_ms2b.php
ovn_ms2c.php
ovn_ms3.php
ovn_ms3create.php
ovn_ms3init.php
ovn_ms3insert.php
ovn_ms3view.php
ovn_rep1.php
ovn_rep2.php
ovn_rep3.php
ovn_rep3a.php
ovn_str1.php
ovn_str1a.php
ovn_str2.php
ovn_str2a.php
ovn_str3.php
ovn_str3a.php
ovn_str4.php
ovn_str4a.php
ovn_str5.php
ovn_str5a.php
ovn_str6.php
ovn_str6a.php
testFramework.php
ovn_ms3insert.php
93 lines UTF-8 Windows (CRLF)
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
<?php
require ('../incl/dbconnection.php');
$ownersql= "SELECT * FROM owners";
$stmt = $dbconn->prepare($ownersql);
$stmt->execute();
?>
<html>
<form action="ovn_ms3insert.php" method="POST">
<table>
<tr>
<td>Registreringsnummer:</td>
<td><input type="text" name="regnum"></td>
</tr>
<tr>
<td>Färg:</td>
<td><input type="text" name="color"></td>
</tr>
<tr>
<td>Garage:</td>
<td><select name="garage">
<?php
$sql= "SELECT * FROM garage";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
echo("<option value=".htmlentities($res["namn"]).">".htmlentities($res["namn"])."</option>");
}
?>
</select></td>
</tr>
<tr>
<td>Ägare:</td>
<td><select name="owners">
<?php
$sql= "SELECT * FROM owners";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
echo("<option value=".htmlentities($res["namn"]).">".htmlentities($res["namn"])."</option>");
}
?>
</select></td>
</tr>
<tr>
<td>Alla fält är obligatoriska:</td>
<td><input type="submit"></td>
</tr>
</table>
</form>
</html>
<?php
if(isset($_POST['regnum']) && isset($_POST['color'])){
$newregnum = $_POST['regnum'];
$newcolor = $_POST['color'];
$garage = $_POST['garage'];
$owner = $_POST['owners'];
$sql= "SELECT garageid FROM garage WHERE namn=?";
$stmt = $dbconn->prepare($sql);
$data = ["$garage"];
$stmt->execute($data);
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$newgarage = $res['garageid'];
}
$sql= "SELECT ownerid FROM owners WHERE namn=?";
$stmt = $dbconn->prepare($sql);
$data = ["$owner"];
$stmt->execute($data);
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$newowner = $res['ownerid'];
}
try {
$sql = 'INSERT INTO car (regnr,color,cargarage,carowner) VALUES (?,?,?,?)';
$stmt = $dbconn->prepare($sql);
$data = [$newregnum,$newcolor,$newgarage,$newowner];
$stmt->execute($data);
echo "car inserted successfully";
}
catch(PDOException $e){
echo $sql."<br>".$e->getMessage();
}
}
?>