Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of RegistrationForm
- *
- * @author Bartosz
- */ include_once('klasy/User.php');
- class RegistrationForm {
- //put your code here
- protected $user;
- function __construct(){ ?>
- <h3>Formularz rejestracji</h3><p>
- <form action="index.php" method="post">
- Nazwa użytkownika: <br/><input name="userName" /><br/>
- Imie i Nazwisko: <br/><input name="fullName" /><br/>
- Haslo: <br/><input name="passwd" /><br/>
- Email: <br/><input name="email" /><br/>
- <input type="submit" />
- </form></p>
- <?php
- }
- function checkUser(){ // podobnie jak metoda validate z lab4
- $args = [
- 'userName' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/'] ],
- 'fullName' => ['filter' => FILTER_VALIDATE_REGEXP,'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/'] ],
- 'passwd' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[0-9A_Za-ząęłńśćźżó_-]{2,25}$/']],
- 'email' => ['filter' => FILTER_VALIDATE_EMAIL ] ];
- $dane = filter_input_array(INPUT_POST, $args);
- $errors = "";
- foreach ($dane as $key => $val) {
- if ($val === false or $val === NULL) {
- $errors .= $key . " ";}
- }
- if ($errors === "") {
- $this->user=new User($dane['userName'], $dane['fullName'],
- $dane['email'],$dane['passwd']);
- } else {
- echo "<p>Błędne dane:$errors</p>";
- $this->user = NULL;
- }
- return $this->user;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement