Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/25/2021 in all areas

  1. <html lang="en"> <head> <!-- SEO --> <meta content="Test, PHP, JS" name="keywords" /> <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" name="viewport"> <meta content="ie=edge" http-equiv="X-UA-Compatible"> <meta content="DHIF19 Test" name="description"> <meta charset="UTF-8" /> <!-- Fonts --> <link href="https://fonts.gstatic.com" rel="preconnect"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> <!-- Bootstrap --> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" rel="stylesheet"> <script crossorigin="anonymous" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"></script> <style> * { font-family: Montserrat, sans-serif; margin: 5px; } </style> <title>DHIF19 | Beispiel 2</title> </head> <body> <?php // 1. Erste Abarbeitung (Assoziatives Array Ausgabe) print_r($_POST); // 2. Zweite Abarbeitung (Berechnen einer Potenz) // Button btn1 ist der "Schreibe-Button" // Ich mache hier Number 1 und Number 2 global, ist leichter fuer mich $num1 = $_POST['num1']; $num2 = $_POST['num2']; if (isset($_POST["btn1"])) { $result = pow($num1, $num2); echo "<br>" . "Die Potenz ergibt folgendes Ergebnis: " . $result; } if (isset($_POST["btn2"])) { $file = fopen("daten.txt", "a+"); fputs($file, $num1); fputs($file, " und "); fputs($file, $num2); fputs($file, " wurden eingelesen!"); fputs($file, "\n"); fclose($file); echo "<p>Im iFrame spiegeln sich die Daten ab, die eingegeben wurden: </p>"; echo "<iframe src='daten.txt' name='show' frameborder='0' style='width: 25%; height: 25vh;'></iframe>"; echo "<br>" . "<a href='table.php'>Hier zur Table Datei</a>"; } // Hier machen wir eine random Number zwischen 1 und 20 einfach so :) // KW Logik - Wenn man Button 3 drueckt, dann muss bei Action ja table.php stehen, ums zum funzen zu bringen ;) $randomnumber = rand(1, 20); if (isset($_POST["btn3"])) { print_r($_POST); echo "<br>"; echo "<br>"; if (empty($_POST["num1"]) || empty($_POST["num2"])) { echo "<p style='text-align:center;'><strong>[-]</strong> Vergessen, Werte einzutragen!</p>"; } else { echo "<div class='container'>"; echo "<table class='table table-striped table-hover'>"; echo "<thead>"; echo "<tr>"; for ($i = 0; $i < $_POST["num1"]; $i++) { echo "<th style='text-align: center;' scope='col'>(-‿-)</th>"; } echo "</tr>"; echo "</thead>"; echo "<tbody>"; for ($i = 0; $i < $_POST["num2"]; $i++) { echo "<tr>"; for ($j = 1; $j < $_POST["num1"] + 1; $j++) { echo "<td style='text-align: center;'>", $randomnumber, "</td>"; } echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "</div>"; } } ?> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <!-- SEO --> <meta content="Test, PHP, JS" name="keywords" /> <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" name="viewport"> <meta content="ie=edge" http-equiv="X-UA-Compatible"> <meta content="DHIF19 Test" name="description"> <meta charset="UTF-8" /> <!-- Fonts --> <link href="https://fonts.gstatic.com" rel="preconnect"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> <!-- Bootstrap --> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" rel="stylesheet"> <script crossorigin="anonymous" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"></script> <style> * { font-family: Montserrat, sans-serif; } #filename { width: 40%; } #num1, #num2 { width: 15%; } button { margin-top: 1.5em; } </style> <!-- JS --> <script> const makealert = () => { alert("Mashallah, hier ist ein Alert mit Pfeilfunktion, das kann der KW nicht hahah") } </script> <title>DHIF19 | Beispiel 1</title> </head> <body> <!-- Simple HTML Datei ohne besondere Angaben --> <div class="container"> <h3 style="margin-bottom: 1.3em; margin-top: 1.3em;">Formular</h3> <form action="welcome.php" method="POST"> <div class="form-group"> <label for="filename">Dateiname</label> <input type="text" class="form-control" name="file" placeholder="Dateiname" id="filename"> </div> <div class="form-group"> <label for="num1">Zahl <strong>a</strong></label> <input type="number" class="form-control" name="num1" placeholder="Gib eine Zahl ein" id="num1"> </div> <div class="form-group"> <label for="num2">Zahl <strong>b</strong></label> <input type="number" class="form-control" name="num2" placeholder="Gib eine Zahl ein" id="num2"> </div> <button type="submit" name="btn1" class="btn btn-primary">Schreibe</button> <button type="submit" name="btn2" class="btn btn-primary">Inhalt</button> <br> <button type="submit" name="btn3" class="btn btn-primary">Tabelle</button> <button name="btn4" onclick="makealert()" class="btn btn-primary">JS Button</button> </form> </div> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> </head> <body class="container" style="background: <?php if (isset($_POST["hintergrund"])) echo $_POST["hintergrund"] ?>"> <h2>Coole PHP Übung</h2> <p>Hintergrundfarbe wird geändert</p> <form action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>" method="POST"> <div class="form-group"> <label for="name">Name:</label> <input type="text" class="form-control" placeholder="Name" name="name" id="name"> </div> <div class="container"> <label for="quantity">Wert:</label> <input type="number" id="wert" name="wert" min="1" max="20"> <input type="submit"> <p>Hintergrundfarbe</p> <div class="form-check"> <label class="form-check-label" for="radio1"> <input type="radio" class="form-check-input" id="radio1" name="hintergrund" value="#FF1234" checked>Rot </label> </div> <div class="form-check"> <label class="form-check-label" for="radio2"> <input type="radio" class="form-check-input" id="radio2" name="hintergrund" value="#FFFF00">Gelb </label> </div> <div class="form-check"> <label class="form-check-label" for="radio3"> <input type="radio" class="form-check-input" id="radio3" name="hintergrund" value="#8FEC95">Grün </label> </div> <div class="form-check"> <label class="form-check-label" for="radio4"> <input type="radio" class="form-check-input" id="radio4" name="hintergrund" value="#FFA000">Orange </label> </div> <button type="submit" class="btn btn-primary" name="absenden">Submit</button> </form> </div> <?php print_r($_POST); // define variables and set to empty values $name = $email = $gender = $comment = $website = ""; if (isset($_POST["absenden"]) && isset($_POST["hintergrund"])) { echo "<p><em>Neuer Hintergrund</em></p>"; } // $name = $_POST["name"]; // $wert = $_POST["wert"]; echo "<br><a>Name: </a>"; if (isset($_POST["name"])) { $name = $_POST["name"]; echo " $name <br>"; $fptr = fopen("cooleAusgabe.txt", "a+"); fputs($fptr, $name . "\n"); fclose($fptr); } echo "<br><a>Wert: </a>"; if (isset($_POST["wert"])) { $wert = $_POST["wert"]; echo " $wert <br>"; $fptr = fopen("cooleAusgabe.txt", "a+"); fputs($fptr, $wert . "\n"); fclose($fptr); } echo "Eingabe: " . $name . " Wert: " . $wert; echo "<br><br><br><a>Alle Eingaben: </a><br>"; $filepointer = fopen("cooleAusgabe.txt", "r"); while (!feof($filepointer)) { $zeile = fgets($filepointer); printf("%s", $zeile); } fclose($filepointer); ?> </body> </html> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://fonts.gstatic.com" rel="preconnect"> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap" rel="stylesheet"> <!-- Bootstrap --> <link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" rel="stylesheet"> <script crossorigin="anonymous" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"></script> <title>Fontsize-Changer</title> <style> * { font-family: Montserrat, sans-serif; } #exampleFormControlTextarea1 { width: 30%; } </style> </head> <body> <h2 style='text-align: center; margin: 1.5em;'> <strong> Change Fontsize </strong> </h2> <div class="container"> <form action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>" method="POST"> <div class="container"> <p></p> <div class="form-group"> <label for="exampleFormControlTextarea1">Change Fontsize</label> <textarea class="form-control" id="exampleFormControlTextarea1" rows="1" name="size"></textarea> <small>You can write all possible ways to change a font-size</small> </div> <br> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </div> </form> </div> <p style=" font-size: <?php if (isset($_POST["size"])) echo $_POST["size"] ?>; text-align: center;"><mark style="background: cyan"> ... Change me ...</mark></p> </body> </html>
    1 point
  2. 1 point
×
×
  • Create New...