Advertisement
Guest User

Untitled

a guest
Jun 27th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1.  
  2. <!doctype html>
  3. <html lang="en">
  4. <head>
  5. <!-- Required meta tags -->
  6. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8.  
  9. <title>Hello, world!</title>
  10. </head>
  11. <body>
  12. <form action="" method="post">
  13. <input type="text" id="liczba1" placeholder="liczba1">
  14. <input type="text" id="liczba2" placeholder="liczba2">
  15. <input type="checkbox" id="checkbox" name="check" value="yes">Dodaj tego tysiaka
  16. <input type="submit" id="submit" name="submit" value="Oblicz">
  17. </form>
  18.  
  19.  
  20.  
  21. </body>
  22. </html>
  23.  
  24.  
  25.  
  26. <?php
  27. $localhost = 'localhost';
  28. $user = 'root';
  29. $password = '';
  30. $db_name = 'baza';
  31.  
  32. $conn = mysqli_connect($localhost, $user, $password, $db_name);
  33. if(!$conn){
  34. echo 'nie polaczono';
  35.  
  36. }
  37.  
  38.  
  39.  
  40. if(isset($_POST['submit'])){
  41. $liczba1 = $_POST['liczba1']
  42. $liczba2 = $_POST['liczba1']
  43. $query = "Insert into tabela('liczba1', 'liczba2') values ({$liczba1}, {$liczba2}";
  44. $result = mysqli_query($conn, $query)
  45. if($result){
  46. echo 'dodano'
  47. }else{
  48. echo 'niedodano'
  49. }
  50. if(isset($_POST['check']) && $_POST['check']=='yes'){
  51. echo 'wcisnieto';
  52. }
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement