Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. insert.php
  2.  
  3. <?php
  4.  
  5. $polaczenie = new mysqli ('localhost','root','','nasza_baza');
  6.  
  7. if (mysqli_connect_errno() != 0)
  8. echo 'cos jest nie tak: '.mysqli_connect_error();
  9.  
  10. $sql ='insert into studenci (imie, nazwisko, plec, data_ur, miasto, ulica, kod, nr_domu, nr_mieszkania) values (?,?,?,?,?,?,?,?,?)';
  11.  
  12. $prep = $polaczenie -> prepare($sql);
  13.  
  14.  
  15. $imie=$_POST['imie'];
  16. $nazwisko=$_POST['nazwisko'];
  17. $plec=$_POST['plec'];
  18. $data_ur=$_POST['data_ur'];
  19. $miasto=$_POST['miasto'];
  20. $ulica=$_POST['ulica'];
  21. $kod=$_POST['kod'];
  22. $nr_domu=$_POST['nr_domu'];
  23. $nr_mieszkania=$_POST['nr_mieszkania'];
  24.  
  25. $prep -> bind_param('sssssssss',$imie,$nazwisko,$plec,$data_ur,$miasto,$ulica,$kod,$nr_domu,$nr_mieszkania);
  26.  
  27. $prep -> execute();
  28. echo 'dodano rekordow: '.$polaczenie->affected_rows;
  29.  
  30. ?>
  31.  
  32.  
  33. form_nasza_baza.html
  34.  
  35. <form method='post' action='insert.php'>
  36.  
  37. <input type='text' name='imie' required placeholder='wpisz imie'>
  38. </br>
  39. <input type='text' name='nazwisko' required placeholder='wpisz nazwisko'>
  40. </br>
  41. <input type='text' name='plec' required placeholder='wpisz plec'>
  42. </br>
  43. <input type='text' name='data_ur' required placeholder='wpisz date urodzenia'>
  44. </br>
  45. <input type='text' name='miasto' required placeholder='wpisz miasto'>
  46. </br>
  47. <input type='text' name='ulica' required placeholder='wpisz ulice'>
  48. </br>
  49. <input type='text' name='kod' required placeholder='wpisz kod pocztowy'>
  50. </br>
  51. <input type='text' name='nr_domu' required placeholder='wpisz nr domu'>
  52. </br>
  53. <input type='text' name='nr_mieszkania' required placeholder='wpisz nr mieszkania'>
  54. </br>
  55.  
  56. <input type='submit' value='clicc me'>
  57. <input type='reset'>
  58.  
  59. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement