<?php
if (isset($_POST['submit'])) {
$task = $_POST['name'];
$count = $_POST['choice'];
$order = $db->prepare("INSERT INTO `Dreams` (Choice, Name) VALUES
('$count', '$task')");
$order->execute();
}
?>
I'm trying to submit information from a form input on a View in code igniter. This code above is at the end, and should submit name and choice.
if ($this->form_validation->run() == FALSE)
{
$this->load->view('bar');
echo validation_errors();
}
else
{
$this->load->view('formsucess');
}
These lines of code are in my controller which begin validation. The problem I'm having is that the first set of code is not executing, and actually pushing the data to the server(the connection and info are all correct, being verified at the beginning of the view's code that establishes the connection). I believe it's because the controller tries to validate before the view can actually push the form data to the database. How do I reconcile this without having to make too many drastic changes?