Guest User

Untitled

a guest
Jan 19th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.48 KB | None | 0 0
  1. /* --- formularz.php --- */
  2. <form action="check.php" method="post" name="formularz">
  3.           <table>
  4.                     <tr>
  5.                               <td class="left">Nick:</td>
  6.                               <td><input type="text" class="input1" name="nick" maxlength="21"></td>
  7.                     </tr>
  8.                     <tr>
  9.                               <td class="left">Password</td>
  10.                               <td> <input type="text" class="input1"  name="password" maxlength="21"></td>
  11.                     </tr>
  12.                     <tr>
  13.                               <td class="left">Password again:</td>
  14.                               <td><input type="text" class="input1"  name="password2" maxlength="21"></td>
  15.                     </tr>
  16.                     <tr>
  17.                               <td class="left">E-mail:</td>
  18.                               <td><input type="text" class="input1"  name="email" maxlength="21"></td>
  19.                     </tr>
  20.                     <tr>
  21.                               <td class="submit" colspan="2"><input type="submit" value="Submit" class="submit"></td>
  22.                     </tr>
  23.           </table>
  24.           </form>
  25.  
  26. /* --- index.php --- */
  27.  
  28. <html>
  29. <head>
  30.           <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  31.           <link rel="Stylesheet" type="text/css" href="style.css" />
  32.           <title>Sprawdzanie poprawnosci formularza</title>
  33. </head>
  34. <body>
  35.           <?php
  36.                      include("check.php");
  37.                      include("formularz.php");
  38.           ?>
  39. </body>
  40. </html>
  41.  
  42. /* --- check.php --- */
  43. <html>
  44.           <head>
  45.                     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  46.                     <link rel="Stylesheet" type="text/css" href="style.css" />
  47.           </head>
  48.           <body>        
  49. <?php
  50. if (($_SERVER['REQUEST_METHOD'] == 'POST')) {// wejście postem
  51.                    
  52.           $nick = $_POST['nick'];
  53.           $password =  $_POST['password'];
  54.           $password2 = $_POST['password2'];
  55.           $email = $_POST['email'];
  56.            /* --- EMAIL --- */
  57.           if(empty ($email))
  58.                     echo "Pole mail nie może być puste!<br>";
  59.           else{
  60.                    if(!strstr($email,'@') || strlen($email)<7)
  61.                            echo "Nie poprawny adres email!<br>";
  62.                    else
  63.                              echo "Twoj mail $email<br>";
  64.           }
  65.          
  66.           /* --- NICK --- */
  67.           if(empty($nick))
  68.                     echo "Pole nick nie może być puste!<br>";
  69.           else{
  70.                     if(strlen($nick)<4)
  71.                               echo "Nick powinien posiadać przynajmniej 4 znaki!<br>";
  72.                     else
  73.                               echo "Twój nick to: $nick<br>";
  74.           }
  75.          
  76.           /* --- HASLO --- */
  77.           if(empty($password))
  78.                     echo "Hasło nie może być puste!<br";
  79.           else{
  80.                      if (strlen($password)<6)
  81.                               echo "Hasło powinno posiadać przynajmniej 6 znaków!<br>";
  82.                     else{
  83.                               if(strcmp($password,$password2) != 0)
  84.                                         echo "Podane hasla różnią się!<br>";
  85.                               else
  86.                                         echo "Twoje haslo to: $password<br>";
  87.                     }
  88.           }
  89.          
  90. }
  91. ?>
  92.           </body>
  93. </html>
Add Comment
Please, Sign In to add comment