redirect to the receipt file

1Tsme1941

Member
Hi, a little prob with code. I have a payment program and want to follow with the receipt. The following
code is the receipt.
1) I've tried to redirect to the receipt file after payment. I have yet to achieve that.
2) I want the receipt# on the receipt. I swear, I'm trying
3) I need to send 3 variables to the receipt program, you're probably laughing thinking how simple this is
I've poured thru the manuals & forums and the discussions are far past my little efforts. Pointers, anything?
---------------------------------
the code:
<?php
echo "<center>";echo date('m/d/y');echo "<br />";

// Include config file
require_once "getprerentdb.php";

//MySqli Select Query
$results = $mysqli->query("SELECT * FROM numberstbl");
$receiptno = "receiptno";
$sql = " UPDATE numberstbl
SET $receiptno = $receiptno + 1 where id=$id ";
echo "receiptno has been updated successfully !";
echo "<center>";echo "Receiptno is $receiptno";echo "<br />"; // doesn't work

$tenant=$_POST['tenant'];
$rentpaid=$_POST['rentpaid'];
$rentdue=$_POST['rentdue'];
?>
<!DOCTYPE html><html>
<head>
<title>rent receipt</title>
</head>
<body><center><font size=+1>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>

For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip">

<TABLE BORDER="0" CELLPADDING="12" CELLSPACING="5" >
<TD>
<TABLE BORDER="30" CELLPADDING="12" CELLSPACING="5">
<td>
<input type='text' size = 30 STYLE="color: #000000; background-color: #D4AAFF;" name="from"
value="<?php echo( htmlspecialchars($row['tenant'] ) ); ?>" /></td>
<td><input type='text' size = 10 STYLE="color: #000000; background-color: D4D4FF;" name="amt"
value="$ <?php echo( htmlspecialchars($row['rentpaid'] ) ); ?>" /></td>
<td><input type='text' size = 10 STYLE="color: #000000; background-color: D4D4FF;" name="due"
value="$ <?php echo( htmlspecialchars($row['rentdue'] ) ); ?>" /></td>
<tr>
<td><input type="text" size="25" name="sign" value="Sign here" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></td>
<td colspan=2 align="center"><input type="text" size=15 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"></td>
</tr></table>

</b></body></html>
---------------------------------------
05/02/21
receiptno has been updated successfully !
Receiptno is receiptno
------------------------------------------
the payment (from a form) code:
<?php
echo "<center>";echo date('m/d/y');echo "</center>";
$id="''";

// Include config file
require_once "getprerentdb.php";

//MySqli Select Query
$results = $mysqli->query("SELECT * FROM paytbl");

$tenant=$_POST['tenant'];
$unit=$_POST['unit'];
$rentpaid=$_POST['rentpaid'];
$hudpay=$_POST['hudpay'];
$datepaid=$_POST['datepaid'];
$comments=$_POST['comments'];

$tenant='tenant';
$unit='unit';
$rentpaid='rentpaid';
$hudpay='hudpay';
$prevbal='prevbal';
$latechg='latechg';
$secdep='secdep';
$damage='damage';
$courtcost='courtcost';
$nsf='nsf';
$paidsum='paidsum';
$datepaid='datepaid';
$late='late';
$comments='comments';

$owe = $prevbal + $latechg + $secdep + $damage + $courtcost + $nsf;
$rentpaid=$owe; $paidsum=$owe;
?>

<!DOCTYPE html><html>
<head>

<STYLE TYPE="text/css">
.blue {background-color: #ccffff;}
.tan {background-color: #FFD4FF;}
h1.centered-cell {text-align: center;font-size: 1.1em;}
</STYLE>

</head>
<body><center><b><font size=+1>Rent Payment</b><p>

<?php
// ---------------------------------------
while($row = mysqli_fetch_array($results)) {
// ----------------------------------------
if(!empty($_POST["update"]))
{
$mysqli->query("Update paytbl SET
rentpaid = '$rentpaid', datepaid = '$datepaid', paidsum = '$paidsum', hudpay = '$hudpay',
comments = '$comments'
where unit = '$unit'");
}
}
?>

</center></body></html>
 
Your post is a wall, very hard to read.
1) I've tried to redirect to the receipt file after payment. I have yet to achieve that.
2) I want the receipt# on the receipt. I swear, I'm trying
3) I need to send 3 variables to the receipt program, you're probably laughing thinking how simple this is
You say this is what you need to do, breaking the block of code to a small snippet for each part, what is it doing, vs what do you expect?
 
I want to update the table(it says it does but it doesn't) and display the value of the
receiptno(it doesn't)
-----------------------------------------------
the code:
<?php
$link = mysqli_connect("localhost", "root", "", "prerentdb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }

echo "<center>";echo date('m/d/y');echo "<br />";
$id="id";
$unit="unit";
$tenant="tenant";
$rentpaid='rentpaid';
$rentdue='rentdue';
$receiptno='receiptno';

$sql = "UPDATE numberstbl
SET receiptno = $receiptno + 1 where id=$id";
if(mysqli_query($link, $sql)){ echo "record was updated successfully."; }
else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); }
echo "<center>";echo "Receiptno is $receiptno";echo "<br />";
?>
<!DOCTYPE html><html>
<head>
<title>rent receipt</title>
</head>
<body><center>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>

For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<html>
<body>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>

<b> tenant paying is: <?php echo $_POST["tenant"]; ?> -
Amount paid is: <?php echo $_POST["rentpaid"]; ?> -
Rent is: <?php echo $_POST["rentdue"]; ?></b><br>

<input type="text" size=75 name="sign" value="Sign here" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''">
<input type="text" size=25 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>


</b></center></body></html>
 
$receiptno='receiptno';

$sql = "UPDATE numberstbl
SET receiptno = $receiptno + 1 where id=$id";
You are trying to update id = "id" which probably matches 0 rows, so there is nothing to update and therefore, the next issue isn't actually an error (yet) -- $receiptno is text, and you are asking the database to add 1 to it.
 
this code updates the field but I need to display the receiptno on the report.
------------------------------
my code
<?php
$link = mysqli_connect("localhost", "root", "", "prerentdb");
// Check connection
if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }

echo "<center>";echo date('m/d/y');echo "<br />";
$id='id';
$tenant='tenant';
$tenant = $_POST['tenant'];
$rentpaid = $_POST['rentpaid'];
$rentdue = $_POST['rentdue'];

$receiptno="receiptno";

$sql = "UPDATE numberstbl
SET receiptno = $receiptno + 1 where id=1";
if(mysqli_query($link, $sql)){ echo "record was updated successfully."; }
else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); }
echo "<center>";echo "Receiptno is $receiptno";echo "<br />";
?>
<!DOCTYPE html><html>
<head>
<title>rent receipt</title>
</head>
<body><center>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>

For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<html>
<body>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>

<b> tenant paying is: <?php echo $_POST["tenant"]; ?> -
Amount paid is: <?php echo $_POST["rentpaid"]; ?> -
Rent is: <?php echo $_POST["rentdue"]; ?></b><br>

<input type="text" size=75 name="sign" value="Sign here" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''">
<input type="text" size=25 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>
</b></center></body></html>
 
Is the php generating the report, or is the html the report? If the latter, you do not have receiptno echo'd anywhere.
 
The HTML is the report.
Are either/neither of these corect? I use them here and in the PHP.
------------------
<body><center>
<?php
$receiptno="receiptno";
echo $_POST["Receiptno"]; ?><br>

<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>
 
<!DOCTYPE html><html>
<head>
<title>rent receipt</title>
</head>
<body><center>
<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br>

For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>
<html>
<body>
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>

<b> tenant paying is: <?php echo $_POST["tenant"]; ?> -
Amount paid is: <?php echo $_POST["rentpaid"]; ?> -
Rent is: <?php echo $_POST["rentdue"]; ?></b><br>

<input type="text" size=75 name="sign" value="Sign here" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''">
<input type="text" size=25 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>
</b></center></body></html>
This is the html you posted, the code you posted is not in this at all.
 
I completely recoded and I hope u will look at it and offer advice. I hope to combine both
the payment and receipt. I access the file with an html form. I don't understand the
"non numeric error and I'm obviously doing my echoes wrong.
---------------------------------------------------------------------
<!DOCTYPE html><html>
<head>
<title>rent payment and receipt</title>
</head>
<body><center>
<?php
echo "<center>";echo date('m/d/y');echo "</center>";
// Include config file
require_once "getpayments.php";

//MySqli Select Query$results = $conn->query("SELECT * FROM payments");

$unit=$_POST['unit']; $rentpaid=$_POST['rentpaid'];
$hudpay=$_POST['hudpay']; $datepaid=$_POST['datepaid'];

$unit='unit'; $rentpaid='rentpaid'; $rentdue='rentdue'; $hudpay='hudpay';
$prevbal='prevbal'; $latechg='latechg'; $datepaid='datepaid'; $prev="0.00"; $late="0.00";

// if no pay or part pay add $10 to latechg and amount not paid to prevbal
if ($rentpaid < $rentdue)
{ $latechg = $latechg + "10.00"; $prevbal = $rentdue - $rentpaid; }
// if payment = rentdue
elseif ($rentpaid == $rentdue)
{ $prevbal = $prev; $latechg = $late; }

// if over-payment subtract over-payment from prevbal
elseif ($rentpaid > $rentdue )
{
$prevbal = $rentpaid - $rentdue; $latechg = $late; } // *** 29 non numeric both ***

//MySqli Select Query
$results = $conn->query("SELECT receiptno FROM numberstbl");
$receiptno='receiptno';
?>

<!--<img src="apt-pic.jpg" alt="apartment" height=250 width=800><br> -->
For:<SELECT name="options">
<option value="#990033" style="background-color: Violet;">Rent payment</option>
<option value="#003300" style="background-color: Aquamarine;">Background Check</option>
<option value="#6600cc" style="background-color: Pink;">Security Deposit Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Damages Payment</option>
<option value="#990033" style="background-color: Violet;">Late Charges Payment</option>
<option value="#003300" style="background-color: Aquamarine;">Court Costs Payment</option>
<option value="#6600cc" style="background-color: Pink;">NSF Payment</option>
<option value="#990033" style="background-color: Violet;"> </option>
</SELECT><br>

<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Name" value="Business Name -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4D4FF;" name="Addy1" value="Business address -">
<input type="text" size = 25 STYLE="color: #000000; background-color: #D4AAFF;" name="Addy2" value="City, State, Zip"><br>

<b> unit paying is: <?php echo $_POST["unit"]; ?> -
Amount paid is: <?php echo $_POST["rentpaid"]; ?> -
Amount due is: <?php echo $_POST["rentdue"]; ?></b><br> // line 54

<b>Sign here</b><input type="text" size=75 name="sign"><br>
<input type="text" size=25 name="thanks" readonly value="We Thank You:" STYLE="color:
#000000; font-weight: bold; background-color: #ffccff;" onFocus="this.value=''"><br>

<?php
/* Perform a query, check for error */
if(!empty($_POST["update"]))
{
$sql = "UPDATE payments SET
rentpaid='$rentpaid', hudpay='$hudpay', prevbal='$prevbal', latechg='$latechg', datepaid='$datepaid'
where unit = '$unit'";
if ($conn->query($sql) === TRUE) { echo "ng"; }
else { echo "Error updating record: " . $conn->error; }
}
/* Perform a query, check for error */
if(!empty($_POST["update"]))
{
$sql = "UPDATE numberstbl SET
receiptno = $receiptno + 1 where id=1";
if ($conn->query($sql) === TRUE) { echo "ng"; }
else { echo "Error updating record: " . $conn->error; }
$conn->close();
}
?>
</center></body></html>
-------------------------------
errors:
06/26/21

Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 29

Warning: A non-numeric value encountered in C:\xampp\htdocs\property\payment.php on line 29
For:

unit paying is: apt1 - Amount paid is: 530.00 - Amount due is:
Notice: Undefined index: rentdue in C:\xampp\htdocs\property\payment.php on line 54

Sign here
 
Last edited:
Back
Top