Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago