MySQL-Aufgaben, 2024-10-23

<?php
session_start ();
?>

<form method="POST" action="./form20241022.php">
<input type="text" name="form20241022_001"></input>
<input type="submit">
</form>

<?php
echo session_id () . "<br>\n";

setcookie ("form20241022_002", "Dies ist das erste cookie", time () + 3600);

echo htmlentities ($_POST ["form20241022_001"]) . "<br>\n";
echo htmlentities ($_COOKIE ["form20241022_002"]) . "<br>\n";
echo htmlentities ($_COOKIE ["form20241022_003"]) . "<br>\n";

session_destroy ();
?>

Naechstes:

POST http://localhost/david/20241022/form20241022.php HTTP/1.1
host: localhost
Cookie: form20241022_003=Das ist das zweite cookie
Content-Length: 41
Content-Type: application/x-www-form-urlencoded

form20241022_001=Hallo, ich bin das Datum

Naechstes:

Trying ::1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
Date: Tue, 22 Oct 2024 07:50:43 GMT
Server: Apache/2.4.62 (Debian)
Set-Cookie: PHPSESSID=hcudoj610rgspfg1j7mh06f573; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: form20241022_002=Dies%20ist%20das%20erste%20cookie; expires=Tue, 22 Oct 2024 08:50:43 GMT; Max-Age=3600
Vary: Accept-Encoding
Content-Length: 228
Content-Type: text/html; charset=UTF-8


<form method="POST" action="./form20241022.php">
<input type="text" name="form20241022_001"></input>
<input type="submit">
</form>

hcudoj610rgspfg1j7mh06f573<br>
Hallo, ich bin das Datum<br>
<br>
Das ist das zweite cookie<br>

naechstes:

<?php
session_start ();

include ("/home/david/MySQLTEST.php");

$db = new PDO ("mysql: host=localhost", $db_user, $db_password);

$sql = "CREATE DATABASE MySQL20241022" . session_id () . "; ";
$db->query ($sql);

try {
    $sql = "USE MySQL20241022" . session_id () . "; ";
    $db->query ($sql);

    $sql = "CREATE TABLE X (x1 INTEGER, x2 INTEGER); CREATE TABLE Y (y1 INTEGER, y2 INTEGER); ";
    $db->query ($sql);

    $sql =  "INSERT INTO X (x1, x2) VALUES (0, 0); ";
    $sql .= "INSERT INTO X (x1, x2) VALUES (0, 1); ";
    $sql .= "INSERT INTO X (x1, x2) VALUES (1, 0); ";
    $sql .= "INSERT INTO X (x1, x2) VALUES (1, 1); ";
    $sql .= "INSERT INTO X (x1, x2) VALUES (2, 2); ";
    $sql .= "INSERT INTO Y (y1, y2) VALUES (0, 1); ";
    $sql .= "INSERT INTO Y (y1, y2) VALUES (1, 1); ";

    $db->query ($sql);

    $sql = "SELECT x1, x2 FROM X; ";
    $stmt = $db->query ($sql);
    while ($row = $stmt->fetch ())
        echo $row [0] . ", " . $row [1] . "<br>\n";
    echo "<br>\n";

    $sql = "SELECT y1, y2 FROM Y; ";
    $stmt = $db->query ($sql);
    while ($row = $stmt->fetch ())
        echo $row [0] . ", " . $row [1] . "<br>\n";
    echo "<br>\n";

    $sql = "SELECT x1, x2, y1, y2 FROM Y INNER JOIN X; ";
    $stmt = $db->query ($sql);
    while ($row = $stmt->fetch ())
        echo $row [0] . ", " . $row [1] . ", " . $row [2] .", " . $row [3] ."<br>\n";
    echo "<br>\n";


    $sql = "DROP DATABASE MySQL20241022" . session_id () . "; ";
    $db->query ($sql);
}
catch (Exception $e) {
    $sql = "DROP DATABASE MySQL20241022" . session_id () . "; ";
    $db->query ($sql);
}

session_destroy ();
?>
naechstes:
0, 0<br>
0, 1<br>
1, 0<br>
1, 1<br>
2, 2<br>
<br>
0, 1<br>
1, 1<br>
<br>
0, 0, 0, 1<br>
0, 0, 1, 1<br>
0, 1, 0, 1<br>
0, 1, 1, 1<br>
1, 0, 0, 1<br>
1, 0, 1, 1<br>
1, 1, 0, 1<br>
1, 1, 1, 1<br>
2, 2, 0, 1<br>
2, 2, 1, 1<br>
<br>
Image Screenshot_20241022_094732

#!/bin/bash

vorname="David"
nachname="Vajda"

if [[ "$1" == "$vorname" && "$2" == "$nachname" ]]
then
    echo "Hallo, das bin ich"
elif [[ "$1" == "$vorname" && -z "$2" ]]
then
    echo "Jo, das koennte ich sein"
else
    echo "Hallo Welt"
    i=0
    while [ $i -lt 10 ]
    do
        echo "Hallo zum $(($i+1))."
        i=$(($i+1))
    done
    R=(a b c d)
    R+=(e f g h)
    R+=(i j k l)
    i=0
    while [ $i -lt 12 ]
    do
        echo "${R[$i]}"
        i=$(($i+1))
    done
    for s in "${R[@]}"
    do
        echo "$s"
    done
    l=$(ls)
    i=0
    for s in $l
    do
        echo "$s"
        if [ $i -ge 12 ]
        then
            break
        fi
        i=$(($i+1))
    done

    /bin/bash "$0" "$vorname" "$nachname"
    /bin/bash "$0" "$vorname"
fi
Output:
Hallo Welt
Hallo zum 1.
Hallo zum 2.
Hallo zum 3.
Hallo zum 4.
Hallo zum 5.
Hallo zum 6.
Hallo zum 7.
Hallo zum 8.
Hallo zum 9.
Hallo zum 10.
a
b
c
d
e
f
g
h
i
j
k
l
a
b
c
d
e
f
g
h
i
j
k
l
3network
3network.c
a.out
asm16
asm20241022-1.jpg
asm20241022.aux
asm20241022.log
asm20241022.pdf
asm20241022.tex
asmparser15.c
asmparser16
asmparser16.c
aufg-synthese-analyse.c
Hallo, das bin ich
Jo, das koennte ich sein