I wanted to add an input field, where the user can input a name for example and it would be added to the relevant table in the database. However i want to create a new action for this, so far i have the basic input fields and submit button with the following code:
public function action_mynewaction() {
$this->auto_render = false;
if ($this->request->is_ajax())
{
$stmt = DB::query(Database::INSERT, 'INSERT INTO `mytable` (`name`) VALUES (:Name)');
$view = View :: factory('my/form/file_path');
echo $view->render();
}
}
This is my view file where the form is displayed
<table cellspacing="1" cellpadding="5" class="myclass noSort">
<thead>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"> </td>
</tr>
</tfoot>
<tbody>
<tr>
<form action="" method="post">
<td>Add Name</td>
<td><input type="text" name="Name"></td>
<td><input type="submit" value="Submit">
</form>
</tr>
</tbody>
</table>
But whenever i add in my
$stmt->param(':Name', $_POST['name']);
part it doen't show me the input/form field at all?
Doesn't display form/input field at all
public function action_mynewaction() {
$post = $this->request->post();
$stmt = DB::query(Database::INSERT, 'INSERT INTO `mytable` (`name`) VALUES (:Name)');
$stmt->param(':Name', $_POST['name']);
$stmt->execute();
$view = View :: factory('my/form/file_path');
echo $view->render();
}
formelements directly insidetrelements. The only valid children aretdandth.<td><input type="submit" value="Submit">closing</td>missing