Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. a<!DOCTYPE html>
  2. <html lang="pl" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title> PHP </title>
  6.  
  7. <?php
  8. if( isset($_POST['imie']) && isset($_POST['nazwisko']) && isset($_POST['email']) && isset($_POST['haslo']))
  9. {
  10. $wyrazenie = '/^[A-ZŁŚ]{1}+[a-ząęółśżźćń]+$/';
  11. $wyrazenie1 = '/^[a-zA-Z0-9.\-_]+@[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,4}$/';
  12. $imie = $_POST['imie'];
  13. $nazwisko = $_POST['nazwisko'];
  14. $email = $_POST['email'];
  15. $password = $_POST['haslo'];
  16. if(!preg_match($wyrazenie, $imie))
  17. {
  18. $alert1 = "red";
  19. $error = true;
  20. }
  21. if(!preg_match($wyrazenie, $nazwisko))
  22. {
  23. $alert2 = "red";
  24. $error = true;
  25. }
  26. if(!preg_match($wyrazenie1, $email))
  27. {
  28. $alert3 = "red";
  29. $error = true;
  30. }
  31. $uppercase = preg_match('@[A-Z]@', $password);
  32. $lowercase = preg_match('@[a-z]@', $password);
  33. $number = preg_match('@[0-9]@', $password);
  34. $znak = preg_match('@[\!\#\@\$\%\^\&\*\(\)\-\+\=_\/|]@', $password);
  35.  
  36. if(!$uppercase || !$lowercase || !$number || !$znak || strlen($password) < 8) {
  37. $alert4 = "red";
  38. $error = true;
  39. }
  40. if(!isset($error))
  41. {
  42. $db = new PDO('mysql:host=localhost;dbname=badania', 'root', '');
  43. $db->prepare('INSERT INTO pacjenci (imie,nazwisko,email) VALUES (:imie,:nazwisko,:email)');
  44. $db->bindValue(":imie",$imie,"PDO::PARAM_STR");
  45. $db->bindValue(":nazwisko",$nazwisko,"PDO::PARAM_STR");
  46. $db->bindValue(":email",$email,"PDO::PARAM_STR");
  47. $db->execute();
  48. }
  49. }
  50.  
  51.  
  52. ?>
  53. </head>
  54. <body>
  55. <form action="index.php" method="post">
  56. Imię: <input <?php if(isset($alert1)) {echo 'style="background:red;"'; unset($alert1);} ?> type="text" name="imie"><br>
  57. Nazwisko: <input <?php if(isset($alert2)) {echo 'style="background:red;"'; unset($alert2);} ?> type="text" name="nazwisko"><br>
  58. E-mail: <input <?php if(isset($alert3)) {echo 'style="background:red;"'; unset($alert3);} ?> type="text" name="email"><br>
  59. Hasło: <input <?php if(isset($alert4)) {echo 'style="background:red;"'; unset($alert4);} ?> type="password" name="haslo">
  60. <input type="submit" value="Prześlij"><br>
  61. <span style="color:red;">
  62. <?php if(isset($error)){echo "Błędne Dane!"; unset($error);} ?>
  63. </span>
  64. </form>
  65.  
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement