Hi, I'm trying to update a database using MYSQLi using a form and I closed my eyes and got lost.
I think the form is correct but I'm not sure how to state that the update is good (it's not). help!
-----------------------------------------------------
<!DOCTYPE html><html lang="en">
<head>
</head>
<body bgcolor="#ccffff"><center>
<h2><b> record a payment</h2><br>
<form action="payment.php" method="post">
<label for="name">Tenant:</label>
<input type="text" name="tenant" id="tenant">
<label for="unit">Unit:</label>
<input type="text" name="unit" id="unit">
<label for="amtpaid">Amt paid:</label>
<input type="text" name="amtpaid" id="amtpaid"><br>
<input type="submit" name="submit" value="make a payment">
</form></body></html>
-----------------------------------------------------------------------
this is getprerentdb.php code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$DB_NAME = 'prerentdb'; $DB_HOST = 'localhost';
$DB_USER = 'root'; $DB_PASS = '';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno())
{printf("Connect failed: %s\n", mysqli_connect_error());exit();}
?>
------------------------------------
this is php update code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//Open a new connection to the MySQL server
require_once "getprerentdb.php";
//MySqli Select Query
$results = $mysqli->query ('SELECT * FROM `payments`');
echo "<center>";echo date('m/d/y');echo "</center>";
$id="''";
$tenant = $_POST['tenant'];
$unit = $_POST['unit'];
$amtpaid = $_POST['amtpaid'];
?>
<html>
<head></head>
<body onunload="receipts.php"><center><b>Rent Payment</b><br>
<?php
if(!empty($_POST["update"]))
{
$mysqli->query("Update payments SET
amtpaid = '$amtpaid'
Where Id = $Id'") ;
}
?>
</tbody></table></form></center></body></html>
I think the form is correct but I'm not sure how to state that the update is good (it's not). help!
-----------------------------------------------------
<!DOCTYPE html><html lang="en">
<head>
</head>
<body bgcolor="#ccffff"><center>
<h2><b> record a payment</h2><br>
<form action="payment.php" method="post">
<label for="name">Tenant:</label>
<input type="text" name="tenant" id="tenant">
<label for="unit">Unit:</label>
<input type="text" name="unit" id="unit">
<label for="amtpaid">Amt paid:</label>
<input type="text" name="amtpaid" id="amtpaid"><br>
<input type="submit" name="submit" value="make a payment">
</form></body></html>
-----------------------------------------------------------------------
this is getprerentdb.php code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$DB_NAME = 'prerentdb'; $DB_HOST = 'localhost';
$DB_USER = 'root'; $DB_PASS = '';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno())
{printf("Connect failed: %s\n", mysqli_connect_error());exit();}
?>
------------------------------------
this is php update code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//Open a new connection to the MySQL server
require_once "getprerentdb.php";
//MySqli Select Query
$results = $mysqli->query ('SELECT * FROM `payments`');
echo "<center>";echo date('m/d/y');echo "</center>";
$id="''";
$tenant = $_POST['tenant'];
$unit = $_POST['unit'];
$amtpaid = $_POST['amtpaid'];
?>
<html>
<head></head>
<body onunload="receipts.php"><center><b>Rent Payment</b><br>
<?php
if(!empty($_POST["update"]))
{
$mysqli->query("Update payments SET
amtpaid = '$amtpaid'
Where Id = $Id'") ;
}
?>
</tbody></table></form></center></body></html>