Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'newForm.php';
- if (isset($_POST['Submit']) {
- $name = $_POST['name'];
- $hours = $_POST['hours'];
- $time = $_POST['time'];
- $time_1 = $_POST['time_1'];
- $wake_night = $_POST['wake_night'];
- $wake_morning = $_POST['wake_morning'];
- $feel = $_POST['feel'];
- $dream = $_POST['dream'];
- $naps = $_POST['naps'];
- $rate = $_POST['rate'];
- $habits = $_POST['habits'];
- $dark = $_POST['dark'];
- $device = $_POST['device'];
- $alarm = $_POST['alarm'];
- $computer = $_POST['computer'];
- $bedtime = $_POST['bedtime'];
- $insomnia = $_POST['insomnia'];
- $snore = $_POST['snore'];
- $machine = $_POST['machine'];
- $Submit = $_POST['Submit'];
- $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'];
- 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)) {
- $host = 'localhost';
- $user = 'root';
- $password = '';
- $db = 'sleep_assessment';
- $con = new mysqli($host, $user, $password, $db);
- if ($con -> connect_error) {
- die("Connectoion Failed: " . $con -> connect_error);
- }
- $sql = "INSERT into mydb(name, total) VALUES(?, ?)";
- if ($con -> query($sql) == TRUE) {
- echo "new record inserted";
- }else{
- echo "error: " . $sql . "<br>" . $con -> error;
- }
- $con ->close();
- }
- else{
- echo "All options required";
- die();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment