Question

In: Computer Science

PHP The database should have at least two tables with, at minimum, the following fields: Table...

PHP

The database should have at least two tables with, at minimum, the following fields:

Table customers: Fields:

Table billing: Fields:

customer_ID

customer_ID

customer_L_Name

customer_L_Name

customer_F_Name

service

customer_Title (Mr, Ms, Dr. etc,)

customer_bill

street_Address

amt_paid

city_State_Zip

bill_date

customer_Phone

date_paid

customer_Email

Create a PHP page that will extract a customer’s bill amount and the amount paid. Then it will calculate the amount due. If the amount due is greater than 0, an email should be generated and sent to the customer with that amount in the message. If the amount due is zero or there is a credit, generate a thank-you email that thanks the customer for his or her payment and expresses Lee’s wishes for continued business with this customer. Name the main page sendBill.php and be sure to include all the necessary accompanying files when you submit your work.

Solutions

Expert Solution

I have done in my system

with the details provided my you

My database name is " chg" with two tables "customers" and "billing"

screenshot of customers table

screenshot of billing table

Now the Sceenshot of sendbill.php page which will send mail to every customer as per your criteria automatically

Now i am sharing the code:

======================================

<html>
<head>
<title>
Send Bill
</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Customer Bill Details </h2>
<p> it will send email automatically when page reloads</p>
<table class="table table-hover">
<thead>
<tr>
<th>Customer ID</th>
<th>Customer L Name</th>
<th>Bill Amount</th>
<th>Bill Paid</th>
<th>Bill Due</th>
  
</tr>
</thead>
<tbody>
<?php
//data fetched portion
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "chg";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM billing";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$cid= $row["customer_ID"];
$clname= $row["customer_L_Name"];
$cbill= $row["customer_bill"];
$cpaid= $row["amt_paid"];
$cdue= $cbill-$cpaid;
  
?>
  
<tr>
<td><?php echo $cid; ?></td>
<td><?php echo $clname; ?></td>
<td><?php echo $cbill; ?></td>
<td><?php echo $cpaid; ?></td>
<td><?php echo $cdue; ?></td>
  
</tr>
  
<?php
  
  
  
//mailing portion
  
$sql = "SELECT customer_Email FROM customers where customer_ID=".$cid;
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$em=$row["customer_Email"];
}}
  
  

if($cdue=0)
{
  


$mail_sub="Thanks for you payment ";


$header = "MIME-Version: 1.0" . "\r\n";
$header .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$message = 'Thanks for your payment. and your payment due is Zero. Thanks You';


$flag=mail($em,$mail_sub,$message,$header);

  
  
  
  
  
  
}
else if($cdue>0)
{

  
  
$mail_sub="Thanks for you payment ";


$header = "MIME-Version: 1.0" . "\r\n";
$header .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$message = 'Dear Customer ID '.$cid.' This is a gentle reminder that Your Amount Due Rs.'.$cdue.'/- Please Pay Your Due Asap';


$flag=mail($em,$mail_sub,$message,$header);


  
  
}
  
  
  
  
  
  
}
} else {
echo "0 results";
}
$conn->close();
  
  
  
  
?>
  

  
</tbody>
</table>
</div>

</body>
</html>

<?php
echo "<script>window.alert('MAil Sent')</script>";
?>

================================

thank you


Related Solutions

You have a table for a membership database that contains the following fields: MemberLastName,
You have a table for a membership database that contains the following fields: MemberLastName, MemberFirstName, Street, City, State, ZipCode, and InitiationFee. There are 75,000 records in the table. What indexes would you create for the table, and why would you create these indexes?
Implement a Cuckoo hash table in which two separate tables are maintained. Each table should have...
Implement a Cuckoo hash table in which two separate tables are maintained. Each table should have a fixed size of 13. Use the hash function h1(x) = x mod 13 for the first table, and h2(x)= 11 – (x mod 11) for the second table. Your program should read an input file, input.txt, consisting of one input per line, insert the input to the table in order, and print out the final content of the hash table in the provided...
Create a table with a minimum of 10 Records. Each Record should have a Minimum of...
Create a table with a minimum of 10 Records. Each Record should have a Minimum of 8 fields, one of which should be a phone, one a birth date and 1 (Memo) a long Text. Don't forget a Key Field Using Microsoft Access
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation...
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation and error messages Create a MySQL Database Create a table to store submissions from the form Only insert new data into the database when all validation is passed Use PHP to create an HTML table showing all the content of the database   New submissions should appear in table
tableA is a table in a relational database with a composite prime key consisting of fields...
tableA is a table in a relational database with a composite prime key consisting of fields F1 and F2. You have determined that tableA is 1NF. There are four other fields in tableA. Two of them, F10 and F12, are functionally determined by F1. The other two, F50 and F55, are functionally determined by F2. Because all fields are functionally determined by at least a portion of the key, is tableA 2NF?   If you believe the table is not yet...
Please use an Access database with two tables to answer the following: use an example to...
Please use an Access database with two tables to answer the following: use an example to discuss the difference between a right, left, and inner join. Next, perform the left joint, right joint, and inner joint all on the each of the two tables.
Table Rock Tables, manufactures two popular tables, a country style table and a contemporary style table....
Table Rock Tables, manufactures two popular tables, a country style table and a contemporary style table. The manufacturing process for both tables requires the use of three types of machines. The time to produce the tables on each machine given in the following table: Machine   Country Table Contemporary Table Total Time Available Router 1.5 2 1000 Sander 3.0 4.5 2000 Polisher 2.5 1.5 1500 The earns a profit of $350 on the Country table, and $450 on the Contemporary table....
Write a SQL script to add another table to your database. Include these fields in your...
Write a SQL script to add another table to your database. Include these fields in your Product table: Field Name Description Data Type Sample Value ProductID Product ID integer 5 ProductName Product Name varchar(50) candle Description Product Description varchar(255) Bee’s wax candle picUrl Filename of the product’s picture varchar(50) candle.gif Price Product Price decimal 10.99           ProductID should be the Primary Key. It is an auto-increment field.           The Price field stores prices to 7 significant digits and to 2...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to...
I already have a database in phpMyAdmin and need to create an html/php "SEARCH" page to retrieve the information from the database on to my localhost. Please post a php/html code that will create a search page and return the data from my phpmyadmin database. The 3 items I have on the database are first_name, last_name and birth_day.
PHP, JAVASCRIPT, MYSQL below is what I have. Can fill in the details for the database...
PHP, JAVASCRIPT, MYSQL below is what I have. Can fill in the details for the database 5. “Login to DB”, “Logout DB”, sub-menus of “File” 5.1 _____ When the user selects “Login to DB”, a window should popup asking the user to enter login and password. Your program should verify the login and password against the DV_User table in the datamining database. A corresponding message should be shown in the message area when the login failed or successful. If it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT