Guest User

Untitled

a guest
Jul 5th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <?php
  2.  
  3. require 'newForm.php';
  4.  
  5. if (isset($_POST['Submit']) {
  6.  
  7. $name = $_POST['name'];
  8. $hours = $_POST['hours'];
  9. $time = $_POST['time'];
  10. $time_1 = $_POST['time_1'];
  11. $wake_night = $_POST['wake_night'];
  12. $wake_morning = $_POST['wake_morning'];
  13. $feel = $_POST['feel'];
  14. $dream = $_POST['dream'];
  15. $naps = $_POST['naps'];
  16. $rate = $_POST['rate'];
  17. $habits = $_POST['habits'];
  18. $dark = $_POST['dark'];
  19. $device = $_POST['device'];
  20. $alarm = $_POST['alarm'];
  21. $computer = $_POST['computer'];
  22. $bedtime = $_POST['bedtime'];
  23. $insomnia = $_POST['insomnia'];
  24. $snore = $_POST['snore'];
  25. $machine = $_POST['machine'];
  26. $Submit = $_POST['Submit'];
  27.  
  28. $total = $_POST['name'] + $_POST['hours'] + $_POST['time'] + $_POST['time_1'] + $_POST['wake_night'] + $_POST['wake_morning'] + $_POST['feel'] + $_POST['dream'] + $_POST['naps'] + $_POST['rate'] + $_POST['habits'] + $_POST['dark'] + $_POST['device'] + $_POST['alarm'] + $_POST['computer'] + $_POST['bedtime'] + $_POST['insomnia'] + $_POST['snore'] + $_POST['machine'];
  29.  
  30. if (!empty($hours) || !empty($time) || !empty($time_1) || !empty($wake_night) || !empty($wake_morning) || !empty($feel) || !empty($dream) || !empty($naps) || !empty($rate) || !empty($name) || !empty($habits) || !empty($dark) || !empty($device) || !empty($alarm) || !empty($computer) || !empty($bedtime) || !empty($insomnia) || !empty($snore) || !empty($machine)) {
  31.  
  32. $host = 'localhost';
  33. $user = 'root';
  34. $password = '';
  35. $db = 'sleep_assessment';
  36.  
  37. $con = new mysqli($host, $user, $password, $db);
  38.  
  39. if ($con -> connect_error) {
  40. die("Connectoion Failed: " . $con -> connect_error);
  41. }
  42.  
  43. $sql = "INSERT into mydb(name, total) VALUES(?, ?)";
  44.  
  45. if ($con -> query($sql) == TRUE) {
  46. echo "new record inserted";
  47. }else{
  48. echo "error: " . $sql . "<br>" . $con -> error;
  49. }
  50.  
  51. $con ->close();
  52. }
  53. else{
  54. echo "All options required";
  55. die();
  56. }
  57. }
  58.  
  59. ?>
Add Comment
Please, Sign In to add comment