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

Write a program that prompts the user to enter a date in the format mm/dd/yyyy where...
Write a program that prompts the user to enter a date in the format mm/dd/yyyy where mm is the month , dd is the day and yyyy is a 4 digit year Check if the date is valid by seeing month is between 1 and 12, day is between 1 to 31 and year is between 1800 to 3000. Also check that if month is 2, day is between 1 to 29 If the date is valid then display the...
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.
How to tokenize a string date of format        dd/mm/yyyy into day,month and year without using built...
How to tokenize a string date of format        dd/mm/yyyy into day,month and year without using built in function of strok() or any other built in function in C++ (without classes). Kindly help Please .
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...
write program in java Create a class named PersonalDetails with the fields name and address. The...
write program in java Create a class named PersonalDetails with the fields name and address. The class should have a parameterized constructor and get method for each field.  Create a class named Student with the fields ID, PersonalDetails object, major and GPA. The class should have a parameterized constructor and get method for each field. Create an application/class named StudentApp that declare Student object. Prompts (GUI input) the user for student details including ID, name, address, major and GPA....
Java Q1: Create a class named Triangle, the class must contain: Private data fields base and...
Java Q1: Create a class named Triangle, the class must contain: Private data fields base and height with setter and getter methods. A constructor that sets the values of base and height. A method named toString() that prints the values of base and height. A method named area() that calculates and prints the area of a triangle. Draw the UML diagram for the class. Implement the class. Q2: Write a Java program that creates a two-dimensional array of type integer...
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()...
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()...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT