Show sourcecode
The following files exists in this folder. Click to view.
hej.php
hej.py
index.php
ovn_ajax1.php
ovn_ajax2.php
ovn_ajax3.php
ovn_cookie1.php
ovn_cookie2.php
ovn_cookie3_1.php
ovn_cookie3_2.php
ovn_cookie4.php
ovn_cookie5.php
ovn_cookie6.php
ovn_form1.php
ovn_form2.php
ovn_form3_1.php
ovn_form3_2.php
ovn_form7_1.php
ovn_form7_2.php
ovn_form8_1.php
ovn_form_tillamp1_1.php
ovn_form_tillamp1_2.php
ovn_form_tillamp2.php
ovn_form_tillamp3.php
ovn_form_tillamp4.php
ovn_form_tillamp5.php
ovn_form_tillamp6.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_gr7.php
ovn_incl1/
ovn_incl2/
ovn_incl3/
ovn_klass1.php
ovn_klass2.php
ovn_klass3.php
ovn_klass4.php
ovn_klass5.php
ovn_klass6.php
ovn_klass7.php
ovn_mysqlintro1_1.php
ovn_mysqlintro1_2.php
ovn_mysqlintro1_3.php
ovn_mysqlintro1_4.php
ovn_mysqlintro1_5.php
ovn_mysqlintro2_1.php
ovn_mysqlintro2_2.php
ovn_mysqlintro2_3.php
ovn_str1_1.php
ovn_str1_2.php
ovn_str2_1.php
ovn_str2_2.php
ovn_str3_1.php
ovn_str3_2.php
ovn_str4_1.php
ovn_str4_2.php
ovn_str5_1.php
ovn_str5_2.php
ovn_str6_1.php
ovn_str6_2.php
ovn_mysqlintro1_5.php
162 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mysql</title>
</head>
<body>
<?php
include ('../incl/dbconnect.php');
$message = null;
$getid = null;
$getfirstname = null;
$getlastname = null;
$getmobil = null;
$getepost = null;
if (isset($_POST['firstname']) && isset($_POST['lastname']) &&
isset($_POST['id']) && isset($_POST['mobil']) &&
isset($_POST['epost']) && !empty($_POST['firstname']) &&
!empty($_POST['lastname']) && !empty($_POST['id']) &&
!empty($_POST['mobil']) && !empty($_POST['epost'])) {
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$mobil = $_POST['mobil'];
$epost = $_POST['epost'];
try {
# prepare
$sql = "UPDATE kompisar SET firstname=?, lastname=?, mobil=?, epost=?
WHERE id=?";
$stmt = $dbconn->prepare($sql);
# the data we want to insert
$data = array($firstname, $lastname, $mobil, $epost, $id);
# execute width array-parameter
$stmt->execute($data);
$message .= "<br />Record updated successfully.<br />";
// clear form from info
$_GET['id'] = null;
}
catch(PDOException $e)
{
$message .= $sql . "<br>" . $e->getMessage();
}
} else {
$message .= "<br />Först väljer du en post.
Sen måste du fylla i minst förnamn och efternamn!<br /><br />";
}
if (isset($_GET['id']) && !empty($_GET['id']) ) {
$id = $_GET['id'];
try {
# prepare
$sql = "SELECT * FROM kompisar WHERE id=?";
$stmt = $dbconn->prepare($sql);
# the data we want to insert
$data = array($id);
# execute width array-parameter
$stmt->execute($data);
$res = $stmt->fetch(PDO::FETCH_ASSOC);
$getid = htmlentities($res['id']);
$getfirstname = htmlentities($res['firstname']);
$getlastname = htmlentities($res['lastname']);
$getmobil = htmlentities($res['mobil']);
$getepost = htmlentities($res['epost']);
$message .= "<br />Record was selected successfully.<br />";
}
catch(PDOException $e)
{
$message .= $sql . "<br>" . $e->getMessage();
}
} else {
$message .= "<br />Välj en ny post att uppdatera.<br /><br />";
}
echo $message;
?>
<form method="post" action="">
<table>
<tr>
<td>Förnamn*:</td>
<td>
<input type="text" name="firstname" size="40" maxlength="40"
value="<?= $getfirstname; ?>">
</td>
</tr>
<tr>
<td>Efternamn*:</td>
<td>
<input type="text" name="lastname" size="40" maxlength="40"
value="<?= $getlastname; ?>">
</td>
</tr>
<tr>
<td>mobil:</td>
<td>
<input type="text" name="mobil" size="20" maxlength="20"
value="<?= $getmobil; ?>">
</td>
<td>epost:</td>
<td>
<input type="text" name="epost" size="20" maxlength="20"
value="<?= $getepost; ?>">
</td>
</tr>
<tr>
<td>* = obligatoriskt</td>
<td>
<button type="submit">Lägg till</button>
<input type="hidden" name="id" value="<?= $getid; ?>">
</td>
</tr>
</table>
</form>
<?php
// Ouput table with all posts
/*** The SQL SELECT statement ***/
$sql = "SELECT * FROM kompisar";
$stmt = $dbconn->prepare($sql);
// fetch width column names, create a table
$data = array();
$stmt->execute($data);
$output = "<table><caption>En ostylad tabell!</caption>";
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
$idx = htmlentities($res['id']);
$first = htmlentities($res['firstname']);
$last = htmlentities($res['lastname']);
$mobil = htmlentities($res['mobil']);
$epost = htmlentities($res['epost']);
$output .= "<tr>".
"<td><a href='?id=$idx'>$idx</a></td>".
"<td>$first</td>".
"<td>$last</td>".
"<td>$mobil</td>".
"<td>$epost</td>".
"</tr>";
}
$output .= "</table>";
echo "$output";
$dbconn = null;
?>
</body>
</html>