You can try something like this:
updateform.php
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {
separate tags from user input:
$firstline= trim(strip_tags($_POST['first_line'])); $secondline= trim(strip_tags($_POST['second_line']));
create request:
$myquery = "INSERT INTO tablename (firstline, secondline) VALUES ($firstline', '$secondline')";
execute the request (confirm success / failure if / else):
if (@mysqli_query($database, $myquery)) { print '<p>Entries accepted</p>'; } else { print '<p style="color: red;">Could not INSERT values because:<br />' . mysqli_error($database) . '</p>; } } ?>
Then enter the form values ββfor the query variables:
<form action="updateform.php" method="post"> <tr> <td>Firstline</td> <td><input type="text" name="firstline" size="20" value= <?php if (isset($_POST['firstline'])) { print htmlspecialchars($_POST['first_line']); } ?> /></td> <tr> <td>Secondline</td> <td><input type="text" name="secondline" size="20" value= <?php if (isset($_POST['secondline'])) { print htmlspecialchars($_POST['second_line']); } ?> /></td>
<tr> <td></td> <td><input type="submit" name="submit" value="Update" class="btn btn-success btn-lg"/></td> </tr> <tr> <td></td> <td><input type="delete" name="submit" value="Delete" class="btn btn-success btn-lg"/></td>
source share