Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a<!DOCTYPE html>
- <html lang="pl" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title> PHP </title>
- <?php
- if( isset($_POST['imie']) && isset($_POST['nazwisko']) && isset($_POST['email']) && isset($_POST['haslo']))
- {
- $wyrazenie = '/^[A-ZŁŚ]{1}+[a-ząęółśżźćń]+$/';
- $wyrazenie1 = '/^[a-zA-Z0-9.\-_]+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,4}$/';
- $imie = $_POST['imie'];
- $nazwisko = $_POST['nazwisko'];
- $email = $_POST['email'];
- $password = $_POST['haslo'];
- if(!preg_match($wyrazenie, $imie))
- {
- $alert1 = "red";
- $error = true;
- }
- if(!preg_match($wyrazenie, $nazwisko))
- {
- $alert2 = "red";
- $error = true;
- }
- if(!preg_match($wyrazenie1, $email))
- {
- $alert3 = "red";
- $error = true;
- }
- $uppercase = preg_match('@[A-Z]@', $password);
- $lowercase = preg_match('@[a-z]@', $password);
- $number = preg_match('@[0-9]@', $password);
- $znak = preg_match('@[\!\#\@\$\%\^\&\*\(\)\-\+\=_\/|]@', $password);
- if(!$uppercase || !$lowercase || !$number || !$znak || strlen($password) < 8) {
- $alert4 = "red";
- $error = true;
- }
- if(!isset($error))
- {
- $db = new PDO('mysql:host=localhost;dbname=badania', 'root', '');
- $db->prepare('INSERT INTO pacjenci (imie,nazwisko,email) VALUES (:imie,:nazwisko,:email)');
- $db->bindValue(":imie",$imie,"PDO::PARAM_STR");
- $db->bindValue(":nazwisko",$nazwisko,"PDO::PARAM_STR");
- $db->bindValue(":email",$email,"PDO::PARAM_STR");
- $db->execute();
- }
- }
- ?>
- </head>
- <body>
- <form action="index.php" method="post">
- Imię: <input <?php if(isset($alert1)) {echo 'style="background:red;"'; unset($alert1);} ?> type="text" name="imie"><br>
- Nazwisko: <input <?php if(isset($alert2)) {echo 'style="background:red;"'; unset($alert2);} ?> type="text" name="nazwisko"><br>
- E-mail: <input <?php if(isset($alert3)) {echo 'style="background:red;"'; unset($alert3);} ?> type="text" name="email"><br>
- Hasło: <input <?php if(isset($alert4)) {echo 'style="background:red;"'; unset($alert4);} ?> type="password" name="haslo">
- <input type="submit" value="Prześlij"><br>
- <span style="color:red;">
- <?php if(isset($error)){echo "Błędne Dane!"; unset($error);} ?>
- </span>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement