Advertisement
wumat

save.php

Jan 17th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $baza = './bazy/test.db';
  5.  
  6. $db = new SQLite3($baza) or die('Nie mogę otworzyć bazy!');
  7.  
  8. /* odbieramy dane z formularza */
  9.     $imie = SQLite3::escapeString(trim($_POST['imie']));
  10.     $email = SQLite3::escapeString(trim($_POST['email']));
  11.  
  12. /* zapisujemy dane do bazy */
  13. if($imie and $email) {
  14.  
  15.     $results = $db->query(sprintf("INSERT INTO przyklad VALUES (NULL, '$imie', '$email')"))
  16.     or die(SQLite3::escapeString($db));
  17.     }
  18.  
  19. while ($row = $results->fetchArray()) {
  20.  
  21.     var_dump($row);
  22.  
  23.     }
  24.  
  25.     if ($results) {
  26.         echo "Dane zostały zapisane do bazy";
  27.     }
  28.     else {
  29.         echo "Dane nie zostały zapisane do bazy";
  30.     }
  31.  
  32.     $db->close();
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement