SHARE
TWEET

Untitled

a guest Feb 20th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. <h3>GET</h3>
  4.  
  5. <?php
  6.  
  7. if($_SERVER['REQUEST_METHOD'] == "POST"){
  8.     echo 'Yarr';
  9. }
  10.  
  11. if(array_key_exists('nev', $_GET) && !empty($_GET['nev'])) {
  12.     echo "Nev: " ,$_GET['nev'], "<br>", "jelszó: " ,$_GET['jelszó'];
  13. }
  14.  
  15. ?>
  16.  
  17.  
  18.  
  19.  
  20.  
  21. <!-- action="" -->
  22. <form method="GET">
  23.     <input type="text" name="nev">
  24.     <input type="password" name="jelszó">
  25.     <input type ="submit">
  26. </form>
  27.  
  28. <br>
  29. <?php
  30. if(array_key_exists('p', $_GET  )&& !empty($_GET['p'])) {
  31.     switch ($_GET['p']) {
  32.         case 'home': echo 'home'; break;
  33.         case 'login': echo 'login'; break;
  34.         default: echo '404'; break;
  35.     }
  36. } else{
  37.     echo "HOME";
  38. }?>
  39. <br>
  40.  
  41. <a href="?p=home">Home</a> <br>
  42. <a href="?p=login">Login</a> <br>
  43.  
  44. <?php
  45.  
  46. function testInput($data) {
  47.     $data = trim($data)
  48.     return $data;
  49. }
  50.  
  51.  
  52. if ($_SERVER['REQUEST_METHOD'] =='POST') {
  53.     $error = "";
  54.  
  55.     if (!array_key_exists('nev', $_POST) || empty($_POST['nev'])) {
  56.         $error .= "A név mező kötelező! <br>";
  57.     }
  58.  
  59.     if (!array_key_exists('jelszó', $_POST) || empty($_POST['jelszó'])) {
  60.         $error .= "A jelszó mező kötelező! <br>";
  61.     }
  62.  
  63. if($error == "") {
  64.     $nev = $jelszó = "";
  65.  
  66.     $nev = $_POST['nev'];
  67.     $jelszó = $_POST['jelszó'];
  68.  
  69.     echo $nev, "," , $jelszó;
  70.  
  71. } else {
  72.     echo $error;
  73. }
  74.  
  75.  
  76. }
  77.  
  78.  ?>
  79.  
  80.  
  81. <H3>POST</H3>
  82.  
  83.  
  84. <form method="POST">
  85.     <input type="text" name="nev">
  86.     <input type="password" name="jelszó">
  87.     <input type ="submit">
  88. </form>
  89.  
  90.  
  91.  
  92. <br>
  93.  
  94.  
  95. Ai930x8e
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top