Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * To change this license header, choose License Headers in Project Properties.
  5.  * To change this template file, choose Tools | Templates
  6.  * and open the template in the editor.
  7.  */
  8.  
  9. /**
  10.  * Description of RegistrationForm
  11.  *
  12.  * @author Bartosz
  13.  */    include_once('klasy/User.php');
  14. class RegistrationForm {
  15.     //put your code here
  16.  
  17.     protected $user;
  18.  function __construct(){ ?>
  19.  <h3>Formularz rejestracji</h3><p>
  20.  <form action="index.php" method="post">
  21.  Nazwa użytkownika: <br/><input name="userName" /><br/>
  22.  Imie i Nazwisko: <br/><input name="fullName" /><br/>
  23.  Haslo: <br/><input name="passwd" /><br/>
  24.  Email: <br/><input name="email" /><br/>
  25.  <input type="submit"  />
  26.  
  27.  </form></p>
  28.  <?php
  29.  }
  30.  function checkUser(){ // podobnie jak metoda validate z lab4
  31.  $args = [
  32.  'userName' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/'] ],
  33.      'fullName' => ['filter' => FILTER_VALIDATE_REGEXP,'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/'] ],
  34.  
  35.  
  36.      'passwd' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/']],
  37.  
  38.  
  39.      'email' => ['filter' => FILTER_VALIDATE_EMAIL ] ];
  40.  
  41.  $dane = filter_input_array(INPUT_POST, $args);
  42. $errors = "";
  43.  foreach ($dane as $key => $val) {
  44.  if ($val === false or $val === NULL) {
  45.  $errors .= $key . " ";}
  46.  
  47.  }
  48.  if ($errors === "") {
  49.  
  50.  $this->user=new User($dane['userName'], $dane['fullName'],
  51.  $dane['email'],$dane['passwd']);
  52.  } else {
  53.  echo "<p>Błędne dane:$errors</p>";
  54.  $this->user = NULL;
  55.  }
  56.  return $this->user;
  57.  }
  58.    
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement