Browse Source

Ajout tp1

KREBS-CHEVRESSON Clément 6 years ago
parent
commit
edf447f76e
11 changed files with 144 additions and 0 deletions
  1. 13 0
      Tp1/bonjour.php
  2. 22 0
      Tp1/bonjourget.php
  3. 22 0
      Tp1/bonjourpost.php
  4. 9 0
      Tp1/counter.php
  5. 9 0
      Tp1/counterpookie.php
  6. 20 0
      Tp1/formulaire.html
  7. 9 0
      Tp1/liste.php
  8. 9 0
      Tp1/listeget.php
  9. 18 0
      Tp1/listepost.html
  10. 9 0
      Tp1/listepost.php
  11. 4 0
      Tp1/resetcounter.php

+ 13 - 0
Tp1/bonjour.php

@@ -0,0 +1,13 @@
+<?php
+    
+    if ($_SERVER['REQUEST_METHOD'] == "POST") {
+    
+        if (isset($_POST['firstname'], $_POST['lastname'])) {
+                
+            echo htmlspecialchars($_POST['firstname']);
+            echo htmlspecialchars($_POST['lastname']);
+        }
+    } else {
+
+        header('Location: https://webetu.iutrs.unistra.fr/~clement.krebs/tp1/formulaire.html');
+    }

+ 22 - 0
Tp1/bonjourget.php

@@ -0,0 +1,22 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <title>Tp 1</title>
+</head>
+<body>
+
+    <p>Salut</p>
+    
+    <?php
+        if (isset($_GET['module']) && !empty($_GET['module'])) {
+            echo htmlspecialchars($_GET['module']);
+        } else {
+            echo "pas ok";
+        }
+    
+    
+    ?>
+
+</body>
+</html>

+ 22 - 0
Tp1/bonjourpost.php

@@ -0,0 +1,22 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <title>Tp 1</title>
+</head>
+<body>
+
+    <p>Salut</p>
+    
+    <?php
+        if (isset($_GET['module']) && !empty($_GET['module'])) {
+            echo htmlspecialchars($_GET['module']);
+        } else {
+            echo "pas ok";
+        }
+    
+    
+    ?>
+
+</body>
+</html>

+ 9 - 0
Tp1/counter.php

@@ -0,0 +1,9 @@
+<?php
+    session_start();
+    $_SESSION['counter']++;
+    echo($_SESSION['counter']);
+    echo("<a href='https://webetu.iutrs.unistra.fr/~clement.krebs/tp1/resetcounter.php'>Reset</a>");
+
+
+    
+  

+ 9 - 0
Tp1/counterpookie.php

@@ -0,0 +1,9 @@
+<?php
+    setcookie('counter','0');
+    $_COOKIE['counter']++;
+    echo($_COOKIE['counter']);
+    echo("<a href='https://webetu.iutrs.unistra.fr/~clement.krebs/tp1/resetcounter.php'>Reset</a>");
+
+
+    
+  

+ 20 - 0
Tp1/formulaire.html

@@ -0,0 +1,20 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <title>Tp 1</title>
+</head>
+<body>
+
+    <p>Salut</p>
+    
+    <form action="bonjour.php" method="post">
+    First name :<br>
+    <input type="text" name="firstname"><br>
+    Last name :<br>
+    <input type="text" name="lastname"><br>
+    <input type="submit" value="s">
+    </form>
+
+</body>
+</html>

+ 9 - 0
Tp1/liste.php

@@ -0,0 +1,9 @@
+<?php
+    echo("<ul>");
+    for ($i = 0; $i < 10; $i++) {
+        if (gettype($i) == "integer") {
+            $d = (string) $i;
+            echo("<li>" . $d . "</li>");
+        }
+    }
+    echo("</ul>");

+ 9 - 0
Tp1/listeget.php

@@ -0,0 +1,9 @@
+<?php
+    echo("<ul>");
+    for ($i = 0; $i < $_GET['nbitems']; $i++) {
+        if (gettype($i) == "integer") {
+            $d = (string) $i;
+            echo("<li>" . $d . "</li>");
+        }
+    }
+    echo("</ul>");

+ 18 - 0
Tp1/listepost.html

@@ -0,0 +1,18 @@
+<!doctype html>
+<html lang="fr">
+<head>
+  <meta charset="utf-8">
+  <title>Tp 1</title>
+</head>
+<body>
+
+    <p>Salut</p>
+    
+    <form action="listepost.php" method="post">
+    nb :<br>
+    <input type="text" name="nbitems"><br>
+    <input type="submit" value="s">
+    </form>
+
+</body>
+</html>

+ 9 - 0
Tp1/listepost.php

@@ -0,0 +1,9 @@
+<?php
+    echo("<ul>");
+    for ($i = 0; $i < $_POST['nbitems']; $i++) {
+        if (gettype($i) == "integer") {
+            $d = (string) $i;
+            echo("<li>" . $d . "</li>");
+        }
+    }
+    echo("</ul>");

+ 4 - 0
Tp1/resetcounter.php

@@ -0,0 +1,4 @@
+<?php
+    session_start();
+    unset($_SESSION['counter']);
+    header('Location: https://webetu.iutrs.unistra.fr/~clement.krebs/tp1/counter.php');