Files from 25-03-26 and added missing Files
This commit is contained in:
@@ -4,10 +4,15 @@
|
|||||||
|
|
||||||
Wichtige Informationen
|
Wichtige Informationen
|
||||||
|
|
||||||
- Wir eventuell nie aktuell sein.
|
- Wird eventuell nie aktuell sein.
|
||||||
- Stundenplan - [Link](https://wvss-mannheim.webuntis.com/WebUntis/?school=wvss-mannheim#/basic/timetablePublic/class?entityId=2583)
|
- Stundenplan - [Link](https://wvss-mannheim.webuntis.com/WebUntis/?school=wvss-mannheim#/basic/timetablePublic/class?entityId=2583)
|
||||||
|
|
||||||
|
|
||||||
|
## 25-03-26 - PHP (Unterrichts Projekt)
|
||||||
|
- Registrierung gemacht
|
||||||
|
|
||||||
|
> Es wurden ebenfalls fehlende Datein hinzugefügt
|
||||||
|
|
||||||
## 05-03-26 - packet tracer
|
## 05-03-26 - packet tracer
|
||||||
|
|
||||||
- vlan in packet tracer
|
- vlan in packet tracer
|
||||||
|
|||||||
24
Zweites Jahr/sessions/session_1.php
Executable file
24
Zweites Jahr/sessions/session_1.php
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sessions in PHP: Schritt 1</title>
|
||||||
|
</head>
|
||||||
|
<h1>Sessions in PHP</h1>
|
||||||
|
<h2>Schritt 1</h2>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start(); //Eine Sitzung beginnen
|
||||||
|
$sId=session_id(); //Auslesen der SessionID
|
||||||
|
|
||||||
|
//Speichern von Werten in der superglobalen Variable Session
|
||||||
|
$_SESSION['vorname'] = "Michael";
|
||||||
|
$_SESSION['nachname'] = "Staudt";
|
||||||
|
echo "SID: $sId<br>";
|
||||||
|
echo "<a href ='session_2.php'><br>zur nächsten Seite</a>";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
24
Zweites Jahr/sessions/session_1php
Executable file
24
Zweites Jahr/sessions/session_1php
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sessions in PHP: Schritt 1</title>
|
||||||
|
</head>
|
||||||
|
<h1>Sessions in PHP</h1>
|
||||||
|
<h2>Schritt 1</h2>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start(); //Eine Sitzung beginnen
|
||||||
|
$sId=session_id(); //Auslesen der SessionID
|
||||||
|
|
||||||
|
//Speichern von Werten in der superglobalen Variable Session
|
||||||
|
$_SESSION['vorname'] = "Michael";
|
||||||
|
$_SESSION['nachname'] = "Staudt";
|
||||||
|
echo "SID: $sId<br>";
|
||||||
|
echo "<a href ='sessions_2.php'><br>zur nächsten Seite</a>";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
30
Zweites Jahr/sessions/session_2.php
Executable file
30
Zweites Jahr/sessions/session_2.php
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sessions in PHP: Schritt 2</title>
|
||||||
|
</head>
|
||||||
|
<h1>Sessions in PHP</h1>
|
||||||
|
<h2>Schritt 2</h2>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start(); //Eine Sitzung beginnen
|
||||||
|
$sId=session_id(); //Auslesen der SessionID
|
||||||
|
|
||||||
|
|
||||||
|
//Hinzufügen von Werten zu der superglobalen Variable Session
|
||||||
|
$_SESSION['alter'] = 58;
|
||||||
|
|
||||||
|
|
||||||
|
//Ausgabe von Werten der superglobalen Variable Session
|
||||||
|
echo "Hallo $_SESSION[vorname] $_SESSION[nachname]<br>";
|
||||||
|
|
||||||
|
|
||||||
|
echo "SID: $sId<br>";
|
||||||
|
echo "<a href ='session_3.php'><br>zur nächsten Seite</a>";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
29
Zweites Jahr/sessions/session_3.php
Executable file
29
Zweites Jahr/sessions/session_3.php
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sessions in PHP: Schritt 3</title>
|
||||||
|
</head>
|
||||||
|
<h1>Sessions in PHP</h1>
|
||||||
|
<h2>Schritt 3</h2>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start(); //Eine Sitzung beginnen
|
||||||
|
$sId=session_id(); //Auslesen der SessionID
|
||||||
|
|
||||||
|
|
||||||
|
//Ausgabe von Werten der superglobalen Variable Session
|
||||||
|
//Alle Werte immer noch da
|
||||||
|
echo "Hallo $_SESSION[vorname] $_SESSION[nachname],
|
||||||
|
du bist $_SESSION[alter] Jahre alt, siehst aber aus wie 32!<br>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "SID: $sId<br>";
|
||||||
|
echo "<a href ='session_4.php'><br>zur nächsten Seite</a>";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
32
Zweites Jahr/sessions/session_4.php
Executable file
32
Zweites Jahr/sessions/session_4.php
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Sessions in PHP: Schritt 4</title>
|
||||||
|
</head>
|
||||||
|
<h1>Sessions in PHP</h1>
|
||||||
|
<h2>Schritt 4</h2>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
session_start(); //Eine Sitzung beginnen
|
||||||
|
$sId=session_id(); //Auslesen der SessionID
|
||||||
|
|
||||||
|
echo "SID: $sId<br>";
|
||||||
|
|
||||||
|
//Session beenden
|
||||||
|
session_destroy();
|
||||||
|
$sId = session_id();
|
||||||
|
echo "SID nach destroy: $sId<br>";
|
||||||
|
|
||||||
|
echo "<p>Nach session_destroy() sind die Werte weg: </p>";
|
||||||
|
echo "Vorname: $_SESSION[vorname]<br>";
|
||||||
|
echo "Nachname: $_SESSION[nachname]<br>";
|
||||||
|
echo "Alter: $_SESSION[alter]<br>";
|
||||||
|
|
||||||
|
echo "<a href ='session_1.php'><br>zurück zum Anfang</a>";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
$db_engine ="mysql";
|
$db_engine ="mysql";
|
||||||
$db_name = "E2FI1_2025";
|
$db_name = "portal_e2fi1_2026";
|
||||||
$db_host = "localhost";
|
$db_host = "localhost";
|
||||||
$db_user = "phpmyadmin";
|
$db_user = "phpmyadmin";
|
||||||
$db_password = "server";
|
$db_password = "server";
|
||||||
|
|||||||
14
Zweites Jahr/unterrichts_projekt/pdo_test_ok.php
Executable file
14
Zweites Jahr/unterrichts_projekt/pdo_test_ok.php
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Entry succeded</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>PDO Testset</h1>
|
||||||
|
<h2>Thank You Landing Page</h2>
|
||||||
|
<p>Thank You, you succeded!</p>
|
||||||
|
<p><a href = "pdo_test_form.php">Another Entry?</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
138
Zweites Jahr/unterrichts_projekt/pdo_test_prepared.php
Executable file
138
Zweites Jahr/unterrichts_projekt/pdo_test_prepared.php
Executable file
@@ -0,0 +1,138 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>PDO-Test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
// pdo_test.php
|
||||||
|
require_once "inc/db_connection_function.php";
|
||||||
|
|
||||||
|
// establish db connection
|
||||||
|
$dbh = db_connect();
|
||||||
|
|
||||||
|
|
||||||
|
// get data from form fields:
|
||||||
|
// SQL-Injection-Angriff verhindern durch quote()
|
||||||
|
|
||||||
|
// $u_firstname = $dbh->quote($_REQUEST['firstname']);
|
||||||
|
// $u_lastname = $dbh->quote($_REQUEST['lastname']);
|
||||||
|
// $u_email = $dbh->quote($_REQUEST['email']);
|
||||||
|
|
||||||
|
// SQL-Injection-Angriff (in letztes Feld eingeben)
|
||||||
|
// ');DELETE FROM user WHERE (u_email LIKE '%
|
||||||
|
|
||||||
|
// Insert new record into db
|
||||||
|
|
||||||
|
/* Prepared Statements senden SQL-Befehl und Daten in zwei getrennten Schritten an die Datenbank:
|
||||||
|
|
||||||
|
Prepare: Die Query-Struktur wird festgelegt und kompiliert.
|
||||||
|
Execute: Die Werte werden separat eingesetzt – nur noch als Daten, nie als SQL-Code.
|
||||||
|
|
||||||
|
Da die Struktur schon vor dem Einsetzen der Werte feststeht,
|
||||||
|
kann eine Benutzereingabe die Logik der Query nicht mehr verändern.*/
|
||||||
|
|
||||||
|
$stmt = $dbh->prepare(
|
||||||
|
"
|
||||||
|
INSERT INTO user VALUES (
|
||||||
|
NULL,
|
||||||
|
:input_1,
|
||||||
|
:input_2,
|
||||||
|
:input_3
|
||||||
|
);"
|
||||||
|
);
|
||||||
|
|
||||||
|
// bind with pindParam
|
||||||
|
|
||||||
|
// $stmt->bindParam(":input_1",$_REQUEST['firstname']);
|
||||||
|
// $stmt->bindParam(":input_2",$_REQUEST['lastname']);
|
||||||
|
// $stmt->bindParam(":input_3",$_REQUEST['email']);
|
||||||
|
|
||||||
|
|
||||||
|
// bind with associative array
|
||||||
|
|
||||||
|
$input = [
|
||||||
|
":input_1" => $_REQUEST['firstname'],
|
||||||
|
":input_2" => $_REQUEST['lastname'],
|
||||||
|
":input_3" => $_REQUEST['email']
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
//if bound with pindParam
|
||||||
|
// $stmt->execute();
|
||||||
|
// if bind with associative array
|
||||||
|
$stmt->execute($input);
|
||||||
|
// echo "<p>Insert succeded!</p>";
|
||||||
|
header('location:pdo_test_ok.php');
|
||||||
|
// Weiterleitung
|
||||||
|
}
|
||||||
|
catch(PDOException $e) {
|
||||||
|
$errMsg = $e->getMessage();
|
||||||
|
$errCode = $e->getCode();
|
||||||
|
// echo "<p>Error-Message: $errMsg <br>";
|
||||||
|
// echo "Error-Code: $errCode </p>";
|
||||||
|
|
||||||
|
switch($errCode) {
|
||||||
|
case "23000": $custErrMsg = "<p>Email-Adress already exists!</p>"; break;
|
||||||
|
default: $custErrMsg = "<p>Oooops, something went wrong!</p>";
|
||||||
|
}
|
||||||
|
echo $custErrMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #######################################################
|
||||||
|
|
||||||
|
// Read records form db
|
||||||
|
|
||||||
|
// result consists of multiple rows and columns
|
||||||
|
/* In der Regel auch hier mit Try-Catch-Block */
|
||||||
|
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM user";
|
||||||
|
// $res = $dbh->query($sql);
|
||||||
|
$res = $dbh->query($sql)->fetchAll(); // Converts result set into Array (multi-dim)
|
||||||
|
/*
|
||||||
|
echo "<pre>";
|
||||||
|
print_r($res);
|
||||||
|
echo "</pre>";
|
||||||
|
*/
|
||||||
|
|
||||||
|
foreach($res as $row) {
|
||||||
|
echo "$row[0] | $row[1] | $row[2] | $row[3]<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// result consists of one row and multiple columns
|
||||||
|
$sql = "SELECT * FROM user WHERE u_id = 24";
|
||||||
|
$res = $dbh->query($sql)->fetch();
|
||||||
|
/*
|
||||||
|
echo "<pre>";
|
||||||
|
print_r($res);
|
||||||
|
echo "</pre>";
|
||||||
|
*/
|
||||||
|
echo "<p>Searching User ID 24:<br>";
|
||||||
|
if($res) {
|
||||||
|
echo "User found: $row[1] $row[2]</p>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "No User found</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// result represents one cell
|
||||||
|
$sql = "SELECT u_firstname FROM user WHERE u_id = 24";
|
||||||
|
$firstname = $dbh->query($sql)->fetchColumn();
|
||||||
|
|
||||||
|
echo "<p>Searching First Name of User ID 24:<br>";
|
||||||
|
echo "First Name of User found: $firstname </p>";
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<p><a href = "pdo_test_form.php">Try again!</a></p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
49
Zweites Jahr/unterrichts_projekt/portal/register.php
Normal file
49
Zweites Jahr/unterrichts_projekt/portal/register.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Portal: Registrieren</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>Registrieren</h2>
|
||||||
|
<form>
|
||||||
|
<label>E-Mail: <input name="email"></label><br>
|
||||||
|
<label>Passwort: <input type="password" name="pw" > </label>
|
||||||
|
<button type="submit">Registrieren</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?php
|
||||||
|
require_once '../inc/db_connection_function.php';
|
||||||
|
$dbh = db_connect();
|
||||||
|
$errors = '';
|
||||||
|
|
||||||
|
if(!empty($_REQUEST)) { // Button wurde gedrückt?
|
||||||
|
if($_REQUEST['email'] != '' AND $_REQUEST['pw'] != ''){ // Alle Felder gedrückt?
|
||||||
|
$email = $_REQUEST['email'];
|
||||||
|
$pw = $_REQUEST['pw'];
|
||||||
|
|
||||||
|
$query = "INSERT INTO user VALUES (NULL, :email, :pw)";
|
||||||
|
$stmt = $dbh->prepare($query);
|
||||||
|
|
||||||
|
$stmt->bindParam(':email', $email);
|
||||||
|
$stmt->bindParam(':pw', $pw);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stmt->execute();
|
||||||
|
} catch(PDOException $e){
|
||||||
|
$errMsg = $e->getMessage();
|
||||||
|
$errCode = $e->getCode();
|
||||||
|
|
||||||
|
switch($errCode) {
|
||||||
|
case "23000": $custErrMsg = "<p>Email-Adress already exists!</p>"; break;
|
||||||
|
default: $custErrMsg = "<p>Oooops, something went wrong!</p>";
|
||||||
|
}
|
||||||
|
echo $custErrMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($errors != "") echo $errors;
|
||||||
Reference in New Issue
Block a user