-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsession_handling.php
50 lines (40 loc) · 1.08 KB
/
session_handling.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
<?php
session_start();
include 'includes/settings.inc';
include 'includes/header.inc';
DrawHeaderAndFooter::drawHeader();
$mysqli = new mysqli("localhost", "root", "virtual", "Benutzer");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
if (isset($_POST["Name"])) {
$mysqli->query("INSERT INTO `UserAlter` (`Name`, `Alter`) VALUES ('".$_POST["Name"]."', ".$_POST["Alter"].")");
}
echo "
<header>
<h1>PHP und MySQL - Sessionhandling</h1>
</header>
<form action = \"#\" method=\"post\">
Bitte gib deinen Namen ein:<br />
<input type = \"text\" name = \"Name\"><br />
Bitte gib dein Alter ein:<br />
<input type = \"text\" name = \"Alter\"><br />
<input type = \"submit\" value = \"Eintragen\">
</form>
";
if ($result = $mysqli->query("SELECT * FROM UserAlter")) {
$finfo = $result->fetch_fields();
while ($row = $result -> fetch_assoc())
{
echo $row["Name"];
echo " ist ";
echo $row["Alter"];
echo "<br />";
}
$result->close();
}
DrawHeaderAndFooter::drawFooter();
$mysqli->close();
?>