Hi all,
Excuse my lack of php knowledge.
I’m simply trying to update an sql column with data that is entered in a form.
I have looked over
https://getkirby.com/docs/cookbook/database
and
https://getkirby.com/docs/developer-guide/toolkit/database
The part I’m stuck with is getting the data from the form and updating the database
I can run the following code directly on a page which updates 000718669X with status, 1.
$update = $books->where(‘book’, ‘=’, ‘000718669X’)->update(array( ‘status’ => ‘1’, ‘date’ => ‘NOW()’));
But ideally I need it to be run on form submit, and CODE = submission from the form
$update = $books->where(‘book’, ‘=’, ‘CODE’)->update(array( ‘status’ => ‘1’, ‘date’ => ‘NOW()’));
<tr>
<td valign="top"> <label for="code">Code</label> </td>
<td valign="top"> <input type="text" name="code" maxlength="50" size="30"> </td>
</tr>
<tr>
<td valign="top"> <label for="name">Name</label> </td>
<td valign="top"> <input type="text" name="name" maxlength="50" size="30"></td>
</tr>
<tr>
<td valign="top"> <label for="notes">Notes</label> </td>
<td valign="top"> <textarea name="notes" maxlength="1000" cols="25" rows="6"></textarea> </td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit">
</td>
</tr>
I guess what I’m asking is what would go into the action php file?
I’m using this on the page itself as the c::set in config/config.php was not working with db::select
$db = new Database(array(
‘type’ => ‘mysql’,
‘host’ => ‘127.0.0.1’,
‘database’ => ‘kirbycms’,
‘user’ => ‘xxxx’,
‘password’ => ‘xxxx’
));