Re: Das neue Auswendig lernen und die neuen Übungen -

Image Screenshot_20240416_153528

<?php
session_start ();
?>

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

<?php
setcookie ("form20240416b", "Ich bin das erste Cookie", time () + 1200);

echo session_id () . "<br>n";

echo htmlentities (\$_POST ["form20240416a"]) . "<br>n";
echo htmlentities (\$_COOKIE ["form20240416b"]) . "<br>n";
echo htmlentities (\$_COOKIE ["form20240416c"]) . "<br>n";

session_destroy ();
?>

POST http://localhost/mysql20240217/20240416/form20240416.php HTTP/1.1
host: localhost
Cookie: form20240416c=Ich bin das zweite Cookie
Content-Length: 38
Content-Type: application/x-www-form-urlencoded

form20240416a=Hallo, ich bin das Datum

    Trying ::1...
    Connected to localhost.
    Escape character is '\^]'.
    HTTP/1.1 200 OK
    Date: Tue, 16 Apr 2024 13:39:03 GMT
    Server: Apache/2.4.57 (Debian)
    Set-Cookie: PHPSESSID=e6k6eopf4gnlhc87gdra7ddg4k; path=/
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate
    Pragma: no-cache
    Set-Cookie: form20240416b=Ich%20bin%20das%20erste%20Cookie; expires=Tue, 16 Apr 2024 13:59:03 GMT; Max-Age=1200
    Vary: Accept-Encoding
    Content-Length: 225
    Content-Type: text/html; charset=UTF-8


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

    e6k6eopf4gnlhc87gdra7ddg4k<br>
    Hallo, ich bin das Datum<br>
    <br>
    Ich bin das zweite Cookie<br>

<?php
session_start ();

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

\$db = new PDO ("mysql: host=localhost", \$MYSQL_USER, \$MYSQL_PASSWORD);

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

\$sql = "USE mysql20240416" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "CREATE TABLE a (x1 INTEGER, x2 INTEGER); CREATE TABLE b (y1 INTEGER, y2 INTEGER); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (0, 0); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (0, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (1, 0); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (1, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO a (x1, x2) VALUES (2, 7); ";
\$db->query (\$sql);

\$sql = "INSERT INTO b (y1, y2) VALUES (0, 1); ";
\$db->query (\$sql);

\$sql = "INSERT INTO b (y1, y2) VALUES (1, 0); ";
\$db->query (\$sql);

\$sql = "INSERT INTO b (y1, y2) VALUES (2, 7); ";
\$db->query (\$sql);

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

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

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

\$sql = "DROP DATABASE mysql20240416" . session_id () . "; ";
\$db->query (\$sql);

session_destroy ();
?>

0, 0, 1, 1, 2, <br>
0, 1, 2, <br>0, 0, 0, 1; 0, 1, 0, 1; 1, 0, 1, 0; 1, 1, 1, 0; 2, 7, 2, 7; <br>

<?php
session_start ();

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

\$db = new PDO ("mysql: host=localhost", \$MYSQL_USER, \$MYSQL_PASSWORD);

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

\$sql = "USE q20240416" . session_id () . "; ";
\$db->query (\$sql);

\$sql = "CREATE TABLE a (x INTEGER); CREATE TABLE b (x INTEGER); CREATE TABLE c (x INTEGER); ";
\$db->query (\$sql);

for (\$i = 0;  \$i < 24;  \$i++) {
    \$sql = "INSERT INTO a (x) VALUES (" . rand () % 32 . "); ";
    \$sql .= "INSERT INTO b (x) VALUES (" . rand () % 64 . "); ";
    \$sql .= "INSERT INTO c (x) VALUES (" . rand () % 128 . "); ";
    \$db->query (\$sql);
}

\$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x
                INTERSECT
            SELECT x FROM c
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x
                UNION
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM b
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x
                UNION
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM a
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x
                INTERSECT
            SELECT x FROM (SELECT x FROM c INTERSECT SELECT x FROM a) x
    ) x ORDER BY x; ";
\$stmt = \$db->query (\$sql);
while (\$row = \$stmt -> fetch ())
    echo \$row [0] . ", ";
echo "<br>n;";

\$sql = "DROP DATABASE q20240416" . session_id () . "; ";
\$db->query (\$sql);

session_destroy ();
?>

0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 17, 19, 20, 26, 27, 28, 29, 30, 31, 37, 40, 46, 49, 50, 53, 55, 60, 61, <br>
;2, 4, 5, 6, 8, 9, 10, 12, 13, 17, 19, 22, 25, 27, 28, 30, 42, 44, 49, 57, 63, 67, 72, 73, 75, 78, 84, 93, 99, 101, 119, 126, <br>
;0, 3, 4, 5, 7, 13, 14, 17, 20, 22, 25, 26, 27, 29, 30, 31, 37, 40, 42, 44, 46, 49, 50, 53, 55, 57, 60, 61, 63, 67, 72, 73, 75, 78, 84, 93, 99, 101, 119, 126, <br>
;4, 27, 30, <br>
;5, 17, 30, <br>
;30, 49, <br>
;5, 17, 30, 49, <br>
;5, 17, 30, 49, <br>
;4, 27, 30, 49, <br>
;4, 27, 30, 49, <br>
;4, 5, 17, 27, 30, <br>
;30, <br>
;