0

I am having trouble passing my form data to my database. Config.php is correct, table reads and displays correctly; just can't for the life of me get this to work. Also, I do not do this as an occupation (obviously) just trying to learn.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['type']) && isset($_POST['client']) && isset($_POST['contact']) && 
   isset($_POST['name']) && isset($_POST['date']) && isset($_POST['po']) && isset($_POST['notes'])) {
$sql = "INSERT INTO list (type, client, contact, name, date, po, notes) VALUES (?,?,?,?,?,?,?)";
if ($stmt = $link->prepare($sql)) {
$stmt->bind_param("ssi", $_POST['type'], $_POST['client'], $_POST['contact'], $_POST['name'], 
   $_POST['date'], $_POST['po'], $_POST['notes']);
if ($stmt->execute()) {
header("location: index.php");
exit();
} else {
echo "ERROR! Please Try Again...";
}
$stmt->close();
}
}
$link->close();
}
?>

If it turns out to be a syntax issue; I will hang my head.

  • 1
    `ssi` is not enough values. Pleassse use error reporting, it will tell you the issue. Outputting `ERROR!` is useless, https://www.php.net/manual/en/mysqli.error.php – user3783243 Mar 05 '20 at 03:05
  • Also, not your issue but much easier to read/write `isset($_POST['type'], $_POST['client'], $_POST['contact'], $_POST['name'], $_POST['date'], $_POST['po'], $_POST['notes'])`. – user3783243 Mar 05 '20 at 03:09

0 Answers0