My user submitted data will not go into my database, I have a form in which they insert their information, and then it should just insert into the database. I can connect to my database fine and it picks up the information, it just doesn't insert it?
The form:
<div class="form">
<form id="addsteps" action="add.php" method="post" autocomplete="off">
<div class="field-wrap">
<input type="date" required autocomplete="off" name="date" style="color: black; text-align: center;"/>
</div>
<div class="field-wrap">
<input type="number" required autocomplete="off" name="steps" style="color: black;"/>
</div>
<button type="submit" class="button button-block" name="submit" />Submit</button>
</form>
</div>
The code:
<?php include '../db_connection.php';
session_start();
$unique_id = $_SESSION['unique_id'];
$_SESSION['date'] = $_POST['date'];
$_SESSION['steps'] = $_POST['steps'];
$_POST['date'];
$_POST['steps'];
$date = $link->escape_string($_POST['date']);
$steps = $link->escape_string($_POST['steps']);
$sql = "INSERT INTO step_count (unique_id, date, steps) "
. "VALUES ('$unique_id','$date','$steps')";
?>
It picks up the data fine and when using a var_dump I get
string(81) "INSERT INTO step_count (unique_id, date, steps) VALUES ('1','2017-12-16','12345')"
So I was just wondering where I am going wrong as it won't go into the database?
This is the db_connection file:
<?php
$link = mysqli_connect("localhost", "root", "", "repsandsteps");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
} ?>