Question

In: Computer Science

Create a PHP class named "User" with the following private fields: name, birthdate in yyyy/mm/dd format,...

Create a PHP class named "User" with the following private fields:

name,

birthdate in yyyy/mm/dd format,

age, and

department.

In the class, include getter and setter methods to get and set the values of those variables.

Author a data entry webform using HTML text input boxes and a submit button. When the user clicks on the submit button, a "User" class is instantiated and the new User object's fields are populated. The HTML input boxes correspond to the field in the "User" class.

Add an "Insert" button that allows the user to insert the form data to a MySQL table.

Add a "Display" button the displays the contents of your MySQL table on the web form when the end-user clicks on the button.

Solutions

Expert Solution

ANSWER:

<! DOCTYPE html>

<html>

<head>

<mete http-equiv="content-type" content="text/html; charset=UTF-8">

</head>

<body>

<form action="insert1.php"method="post">

name:<input type="text" name="name"><br>

Birthday:<input type"date" name="birthday"><br>

Age:<input type ="text" name="age"><br>

  Department : <input type ="text" name="department"><br>

<input type="submit" name="submit">

</form>

</body>

</html>

<?php

define('HOST', 'localhost');

define('USER', 'root');

define('PASS', 'password');

define('DBNAME', 'database');

$db = new mysqli(HOST, USER, PASS, DBNAME);

if ($db=>connect_errno) {echo "failed to connect to mySQL:(" .$db->connect_errno .") " . $db->connect _error;}

if ($_POST['submit']) {

$name = $_POST[ 'name'];

$birthday =$_POST['birthday'];

$age = $POST['age'];

$department =$POST['department'];

if(!empty($name) && !empty($birthday) && !empty($age) && !empty($department)) {

$query = "INSERT INTO form _data (name, birthday , age ,department)

VALUES(?,?,?)" ;

$conn = $db =>prepare($query);

if ($conn ->execute(array(

$name,

$birthday,

$age,

$department

))){

header('location : http://localhost/insert.html');

} else {

echo ' error' ;

}

$db->close();


Related Solutions

Create a class named Horse that contains the following data fields: name - of type String...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races (of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. ------------------------------------ DemoHorses.java public class DemoHorses {     public static void...
In java, create a class named Contacts that has fields for a person’s name, phone number...
In java, create a class named Contacts that has fields for a person’s name, phone number and email address. The class should have a no-arg constructor and a constructor that takes in all fields, appropriate setter and getter methods. Then write a program that creates at least five Contact objects and stores them in an ArrayList. In the program create a method, that will display each object in the ArrayList. Call the method to demonstrate that it works. Include javadoc...
Create a class named “Car” which has the following fields. The fields correspond to the columns...
Create a class named “Car” which has the following fields. The fields correspond to the columns in the text file except the last one. i. Vehicle_Name : String ii. Engine_Number : String iii. Vehicle_Price : double iv. Profit : double v. Total_Price : double (Total_Price = Vehicle_Price + Vehicle_Price* Profit/100) 2. Write a Java program to read the content of the text file. Each row has the attributes of one Car Object (except Total_Price). 3. After reading the instances of...
Create a class named Lease with fields that hold an apartment tenant’s name, apartment number, monthly...
Create a class named Lease with fields that hold an apartment tenant’s name, apartment number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name to “XXX”, the apartment number to 0, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy()...
Design a class named Pet, which should have the following fields: Name – The name field...
Design a class named Pet, which should have the following fields: Name – The name field holds the name of a pet. Type – The type field holds the type of animal that is the pet. Example values are “Dog”, “Cat”, and “Bird”. Age – The age field holds the pet’s age. The Pet class should also have the following methods: setName – The setName method stores a value in the name field. setType – The setType method stores a...
The Account class Create a class named Account, which has the following private properties:
in java The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber (), getBalance (), setBalan newBalance). There is no setNumber () once an account is created, its account number cannot change. Now implement these methods: void deposit (double amount) and void withdraw (double amount). For both these methods, if the amount is less than...
The Account class Create a class named Account , which has the following private properties:
 The Account class Create a class named Account , which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNunber(), getBalance(), setBalance (double newBalance) . There is no setNunber() - once an account is created, its account number cannot change. Now implement these methods: void deposit (double anount) and void withdraw(double anount). For both these methods, if the amount is less than zero,...
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If...
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If the age is greater than 21 print "welcome," and if the age is less than 21 print "sorry." Use input validation to make sure the birthdate was entered correctly.
THIS IS JAVA PROGRAMMING 1. Create a class named Name that contains the following: • A...
THIS IS JAVA PROGRAMMING 1. Create a class named Name that contains the following: • A private String to represent the first name. • A private String to represent the last name. • A public constructor that accepts two values and assigns them to the above properties. • Public methods named getProperty (e.g. getFirstName) to return the value of the property. • Public methods named setProperty ( e.g. setFirstName)to assign values to each property by using a single argument passed...
The Account class Create a class named Account, which has the following private properties: number: long...
The Account class Create a class named Account, which has the following private properties: number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber(), getBalance(), setBalance(double newBalance). There is no setNumber() -- once an account is created, its account number cannot change. Now implement deposit(double amount) and withdraw(double amount) methods. If the amount is less than zero,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT