2024-11-17, MySQL

MySQL20241117.out

0, 0; 0, 1; 1, 0; 1, 1; 4, 5; 0, 1; 1, 0; 4, 5; 0, 0, 0, 1; 0, 1, 0, 1; 1, 0, 1, 0; 1, 1, 1, 0; 4, 5, 4, 5;

MySQL20241117.php

<?php
session_start ();

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

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

$sql = "CREATE DATABASE MySQLTEST20241117; ";
$db->query ($sql);

try {
    $sql = "USE MySQLTEST20241117; ";
    $db->query ($sql);

    $sql = "CREATE TABLE a (x1 INTEGER, x2 INTEGER); ";
    $db->query ($sql);
    $sql = "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 (4, 5); ";
    $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 (4, 5); ";
    $db->query ($sql);

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

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


$sql = "DROP DATABASE MySQLTEST20241117; ";
$db->query ($sql);
session_destroy ();
?>

PHP20241117.php

<?php
session_start ();
?>

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

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

setcookie ("PHP20241117b", "Ich bin das erste Cookie", time () + 3600);

echo htmlentities ($_POST ["PHP20241117a"]) . "<br>\n";
echo htmlentities ($_COOKIE ["PHP20241117b"]) . "<br>\n";
echo htmlentities ($_COOKIE ["PHP20241117c"]) . "<br>\n";

session_destroy ();
?>

PHPhttprequest20241117.in

POST http://localhost/david/20241117/PHP20241117.php HTTP/1.1
host: localhost
Cookie: PHP20241117c=Ich bin das zweite Cookie
Content-Length: 30
Content-Type: application/x-www-form-urlencoded

PHP20241117a=Ich bin das Datum

PHPhttprequest20241117.out

Trying ::1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
Date: Sun, 17 Nov 2024 13:33:08 GMT
Server: Apache/2.4.62 (Debian)
Set-Cookie: PHPSESSID=2iinbc5glu5fc5tur318fba3f5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: PHP20241117b=Ich%20bin%20das%20erste%20Cookie; expires=Sun, 17 Nov 2024 14:33:08 GMT; Max-Age=3600
Vary: Accept-Encoding
Content-Length: 216
Content-Type: text/html; charset=UTF-8


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

2iinbc5glu5fc5tur318fba3f5<br>
Ich bin das Datum<br>
<br>
Ich bin das zweite Cookie<br>

Quantity20241117.php

<?php
session_start ();

include ("/home/david")

session_destroy ();
?>

Image Screenshot_20241117_143405