Question: For my assignment I am suppose to create a database for the Lee's Landscape business called landscape. The database should have at least two tables

For my assignment I am suppose to create a database for the Lee's Landscape business called landscape. 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 customers 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 Lees 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.

How would I connect all of the pages and together to make it work as one Here is my code:

I am unsure if I need 3 separate php pages or can I condense to just one?

landscaping.html

Landcaping Records:

Add Billing Information

Add Customers

customers.html

Enter Customers Information:

Customer ID: Customer Last Name: Customer First Name: Customer Title (Mr, Mrs, Ms, Dr, etc.): Street Address: City, State, and Zip: Customer Phone: Customer Email:

addcustomers.php

$customer_ID = $_POST["customer_ID"]; $customer_L_Name = $_POST["customer_L_Name"]; $customer_F_Name = $_POST["customer_F_Name"]; $customer_Title = $_POST["customer_Title"]; $street_Address = $_POST["street_Address"]; $city_State_Zip = $_POST["city_State_Zip"]; $customer_Phone = $_POST["customer_Phone"]; $customer_Email = $_POST["customer_Email"];

// sql query $sql = "INSERT INTO customers (customer_ID, customer_L_Name, customer_F_Name, customer_Title, street_Address, city_State_Zip, customer_Phone, customer_Email) VALUES ('$customer_ID', '$customer_L_Name', '$customer_F_Name', '$customer_Title', '$street_Address', '$city_State_Zip', '$customer_Phone', '$customer_Email')";

if ($conn->query($sql) === TRUE) { echo "Billing Information added successfully"; } else { echo "Error: " . $sql . " " . $conn->error; }

// close connection $conn->close(); ?>

billing.html

Enter Customers Information:

Customer ID: Customer Last Name: Service: Customer Bill: Amount Paid: Bill Date: Date Paid:

addbilling.php

$customer_ID = $_POST["customer_ID"]; $customer_L_Name = $_POST["customer_L_Name"]; $service = $_POST["service"]; $customer_bill = $_POST["customer_bill"]; $amt_paid = $_POST["amt_paid"]; $bill_date = $_POST["bill_date"]; $date_paid = $_POST["date_paid"];

// sql query $sql = "INSERT INTO billing (customer_ID, customer_L_Name, service, customer_bill, amt_paid, bill_date, date_paid) VALUES ('$customer_ID', '$customer_L_Name', '$service', '$customer_bill', '$amt_paid', '$bill_date', '$date_paid')";

if ($conn->query($sql) === TRUE) { echo "Billing Information added successfully"; } else { echo "Error: " . $sql . " " . $conn->error; }

// close connection $conn->close(); ?> sendBill.php

Send Bill

Customer Bill Details

// 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()) { $customerid= $row["customer_ID"]; $customerlastname= $row["customer_L_Name"]; $customerbill= $row["customer_bill"]; $amountpaid= $row["amt_paid"]; $billdue= ["bill_date"]; $customeremail= ["customer_Email"];

?>

//mailing portion

$sql = "SELECT customer_Email FROM customers where customer_ID=".$customerid; $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" . " "; $header .= "Content-type:text/html;charset=UTF-8" . " "; $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" . " "; $header .= "Content-type:text/html;charset=UTF-8" . " "; $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();

?>

Customer ID Customer L Name Bill Amount Bill Paid Bill Due

database.php

// database credentials $servername = "localhost"; $username = "root"; $password = ""; $dbname = "landscape";

// Create connection $conn = new mysqli($servername, $username, $password, $dbname);

// Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }

?>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!