Advertisement
Guest User

Untitled

a guest
Jan 13th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10.  
  11. <form method="POST" action="x.php">
  12. <input type='text' name='imie'>Podaj imie <br>
  13. <input type='e-mail' name='e_mail'>Podaj e-mail<br>
  14. <input type='text' name='haslo'>Podaj haslo <br>
  15. <input type='text' name='wiek'>Podaj wiek<br>
  16.  
  17. <button>Wyślij</button>
  18. <button type='reset'>Zresetuj</button>
  19.  
  20. </form>
  21. </body>
  22. </html>
  23.  
  24.  
  25.  
  26.  
  27. // NOWY PLIK Z PHP
  28.  
  29. <?php
  30.  
  31.  
  32. $servername = "localhost";
  33. $username = "root";
  34. $password = "";
  35. $DB = "ogloszenia";
  36.  
  37. $conn = new mysqli($servername,$username,$password,$DB);
  38. $imie=$_POST['imie'];
  39. $e_mail=$_POST['e_mail'];
  40. $haslo=$_POST['haslo'];
  41. $wiek=$_POST['wiek'];
  42.  
  43. if($conn->connect_error){
  44. echo 'Błąd z połączeniem z bazą danych '.$DB;
  45. }else{
  46. if($imie !=''){
  47. echo 'Dodano poprawnie rekordy do bazy';
  48. $sql="INSERT INTO `userss` (`ID`, `name`, `e_mail`, `password`, `old`) VALUES (NULL, '".$imie."', '".$e_mail."', '".$haslo."',
  49. '".$wiek."')";
  50. $conn->query($sql);
  51. }else{
  52. echo 'Wystąpił bląd z zmiennymi do dodania.';
  53. }
  54. $conn->close();
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement