CodeLobster IDE

need help updating database
Page 1 of 1

Author:  12Strings [ Wed Mar 18, 2020 3:05 am ]
Post subject:  need help updating database

I'm trying to update a couple of rows in a database using the form below and the php following:

the form:
<!DOCTYPE html><html lang="en">
<meta charset="UTF-8">
<title>update Record Form</title>
<font size=+2><b> update visits & lastused information database</font><br>
<form action="crud-update.php" method="post">
<p><label for="target">target:</label>
<input type="text" name="target" id="target"></p>
<input type="submit" name="submit" value="Submit">
crud-update.php code:
require 'homedb-connect.php';
$target = $_POST["target"];
$visits = visits;
$Lastused = Lastused;
$sql = "UPDATE receiptno SET visits=visits+1, lastused=NOW() WHERE target=$target";
if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; }
{ echo "Error updating record: " . $conn->error; }
This is result. what's wrong?

Author:  Admin [ Tue Mar 24, 2020 2:29 pm ]
Post subject:  Re: need help updating database


Please, try to add quotes to $target

= "UPDATE receiptno SET visits=visits+1, lastused=NOW() WHERE target='".."'";

Codelobster Team.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group