0% found this document useful (0 votes)
5 views3 pages

HTML5 and PHP Form Creation Guide

Uploaded by

hnaila868
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

HTML5 and PHP Form Creation Guide

Uploaded by

hnaila868
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Q1. Describe the difference between client-side programming and server-side programming.

Q2. Create an HTML5 document containing an ordered list of three items—ice cream, soft serve
and frozen yogurt. Each ordered list should contain a nested, unordered list of your favorite flavors.
Provide three flavors in each unordered list.

Q3. A local university has asked you to create an HTML5 document that allows prospective
college students to provide feedback about their campus visit. Your HTML5 document should
contain a form with text fields for a name and e-mail. Provide checkboxes that allow prospective
students to indicate what they liked most about the campus. The checkboxes should include:
campus, students, location, atmosphere, dorm rooms and sports. Also, provide radio buttons that
ask the prospective students how they became interested in the college. Options should include:
friends, television, Internet and other. In addition, provide a text area for additional comments, a
submit button and a reset button.

Q4. Create a website registration form to obtain a user’s first name, last name and e-mail address.
In addition, include an optional survey question that asks the user’s year in college (e.g.,
Freshman). Place the optional survey question in a details element that the user can expand to see
the question.

Q5. Write a CSS rule that changes the color of all elements containing attribute class = "green-
Move" to green and shifts them down 25 pixels and right 15 pixels.

Q6. Make a navigation button using a div with a link inside it. Give it a border, background, and
text color, and make them change when the user hovers the mouse over the button. Use an external
style sheet.
Q7. Create a text shadow on the phrase "New features in CSS3" with a horizontal offset of 2px, a
vertical offset of 5px, a blur radius of 6px and a text-shadow color deepskyblue.

Q8. Create three div elements, each with a width and height of 100px. On the first element, create
slightly rounded corners using a border of 3px black and border-radius of 10px. On the second
element, use a border of 3px black and increase the border-radius to 50px. On the third, use a
border of 3px black and increase the border-radius to 100px. Make the background-color of each
element a different color of your choosing. Inside each element, display the value of the border-
radius in bold text.
Q9. Create three div elements of varying colors, each with a width and height of 200px. On the
first box, add a dimgrey box-shadow with a horizontal offset of 15px, a vertical offset of 15px and
a blur radius of 20px. On the second box, add a dimgrey box-shadow with a horizontal offset of -
15px, a vertical offset of -15px and a blur radius of 30px. On the third box, add a dimgrey box-
shadow with a horizontal offset of 15px, a vertical offset of 15px and a blur radius of 10px.

Q10. Write a script that asks the user to enter two numbers, obtains the two numbers from the user
and outputs text that displays the sum, product, difference and quotient of the two numbers. Use
the techniques shown in below figure:
Q11. Write a script that takes three integers from the user and displays the sum, average, product,
smallest and largest of the numbers in an alert dialog.
Q12. Write a script that reads five integers and determines and outputs markup that displays the
largest and smallest integers in the group. Use only the scripting techniques.

Q13. Drivers are concerned with the mileage obtained by their automobiles. One driver has kept
track of several tankfuls of gasoline by recording the number ofmiles driven and the number of
gallons used for each tankful. Develop a script that will take as input the miles driven and gallons
used (both as integers) for each tankful. The script should calculate and output HTML5 text that
displays the number of miles per gallon obtained for each tankful and prints the combined number
of miles per gallon obtained for all tankfuls up to this point. Use prompt dialogs to obtain the data
from the user.

Q14. Write a script that uses looping to print the following table of values. Output the results in
an HTML5 table. Use CSS to center the data in each column.

Q15. Write a function minimum3 that returns the smallest of three floating-point numbers. Use
the [Link] function to implement minimum3. Incorporate the function into a script that reads
three values from the user and determines the smallest value.
Q16. Create an XML document that marks up the nutrition facts for a package of Grandma White’s
cookies. A package of cookies has a serving size of 1 package and the following nutritional value
per serving: 260 calories, 100 fat calories, 11 grams of fat, 2 grams of saturated fat, 5 milligrams
of cholesterol, 210 milligrams of sodium, 36 grams of total carbohydrates, 2 grams of fiber, 15
grams of sugars and 5 grams of protein. [Hint: Your markup should contain elements describing
the product name, serving size/amount, calories, sodium, cholesterol, proteins, etc. Mark up each
nutrition fact/ingredient listed above.]

Q17. Explain the processing system of XML Documents.


Q18. Explain the validating system of XML Documents.
Q19. Create a form using PHP as below and write appropriate database connection and insertion
code to put the form data in Database (username: user, Password: pass).

Q20. Write a PHP regular expression pattern that matches a string that satisfies the following
description: The string must begin with the (uppercase) letter A. Any three alphanumeric
characters must follow. After these, the letter B (uppercase or lowercase) must be repeated one or
more times, and the string must end with two digits.

Q21. Describe how input from an HTML5 form is retrieved in a PHP program.
Q22. Write a PHP script that tests whether an e-mail address is input correctly. Verify that the
input begins with series of characters, followed by the @ character, another series of characters, a
period (.) and a final series of characters. Test your program, using both valid and invalid e-mail
addresses.

Q23. Write the XHTML code to create a form with the following capabilities
a) A text widget to collect the users name.
b) Four checkboxes one each for the following items:
I. Four 100 watt light bulbs for TK. 200
II. Eight 100 watt light bullbs for TK. 400
III. Four 100 watt LED bulbs for TK. 600
c) A collection of three radio buttons that are labeled as follows:
I. Visa
II. Master Card
III. Discover
Q24. Write the XHTML code to create a form that collects favorite popular songs, including the
name of the song, the composer and the performing artist or group. This document must call the
PHP script when the form is submitted and another to request a current list of survey result.

Common questions

Powered by AI

Client-side programming refers to code that runs in the user's browser, often interacting with the server via network requests. It primarily uses technologies like HTML, CSS, and JavaScript to structure and style the content and provide interactivity without needing to communicate with a server for each user interaction. Server-side programming, on the other hand, involves code that runs on a server and generates content for the browser dynamically. It is responsible for business logic, database interactions, and data processing, typically using languages like PHP, Python, or Java. Client-side programming improves user experience by reducing the server load and providing faster interaction, while server-side programming is crucial for managing data and business logic securely and robustly .

To create a dynamic web form using PHP and connect it with databases, follow these steps: 1) Design the form in HTML with necessary fields. 2) Define a PHP script to retrieve the form data upon submission using $_POST or $_GET. 3) Validate and sanitize inputs to prevent malicious data entry. 4) Establish a database connection using PHP Data Objects (PDO) or MySQLi extensions. 5) Construct an SQL query to insert data into the desired tables. 6) Execute the query, ensuring error handlers manage potential database interaction failures. 7) Provide user feedback about submission success or failure, ensuring a smooth user experience. This process enables data persistence, making information reliably available for future operations or insights .

When data is received from an HTML5 form, PHP scripts are commonly used to validate the input for security and correctness. First, data is retrieved using the $_POST or $_GET superglobals, depending on the form's method attribute. Each input field is typically sanitized by functions such as trim(), stripslashes(), and htmlspecialchars() to prevent code injection. Subsequently, data is validated according to specific criteria—for instance, checking for non-empty values, correct data type, or matching specific formats using regex. If errors are detected, feedback is generated to inform the user, ensuring only clean and valid data is processed or stored in a database, safeguarding the web application against potential security threats .

CSS is pivotal in web design for creating page layouts and styling components, enhancing the visual appeal and usability of web pages. Layouts can be managed using properties like 'display', 'flex', 'grid', 'position', and 'float' to arrange elements precisely. For example, a 'flexbox' layout adapts content responsively, allowing flexible components that adjust size and position dynamically. Styles such as border-radius and box-shadow can create rounded elements and shadow effects, enhancing visual depth and focus. Colors, fonts, and spacing can all be modified, offering an extensive palette for designers to construct engaging, user-friendly, and branded web interfaces efficiently .

PHP regular expressions validate user inputs by defining string patterns that the input must match to be considered valid. For example, a regular expression to validate an email ensures it follows the proper format (characters preceding an '@' symbol, followed by a domain and top-level domain). Regular expressions provide powerful string processing and validation abilities, allowing for concise, efficient checks. Benefits include improved security via input validation, error reduction, and ensuring that data adheres to expected formats before processing, which can prevent malicious data from causing issues in applications .

Server-side scripting languages like PHP are crucial for processing form data as they allow secure handling of sensitive information, interfacing with databases, and executing server-side business logic. They handle form submissions, validate data, and send responses back to the client. However, they also present challenges: maintaining security to guard against vulnerabilities like SQL injection, ensuring performance scalability as user load increases, and managing state in inherently stateless protocols like HTTP. The complexity of server-side applications requires robust error handling and often necessitates frameworks that provide structure and components that facilitate typical tasks, improving development efficiency and application security .

CSS selectors are patterns used to select the elements you want to style in a web page. They act like a bridge between HTML and CSS, allowing specific styles to be applied to elements based on their attributes, such as id, class, or type. For instance, using a CSS selector for a class, such as '.green-Move', the style can be directly altered to change element colors or positioning. This is achieved by defining a rule in the CSS like '.green-Move { color: green; transform: translate(15px, 25px); }', applying a green color and moving elements with this class down and to the right. This mechanism allows for consistent styling across specified elements, enhancing both aesthetic appeal and user experience .

An HTML5 form for capturing feedback from prospective college students should include a text field for the name and e-mail, checkboxes for what they liked most about the campus (options: campus, students, location, atmosphere, dorm rooms, sports), radio buttons to ascertain how they became interested in the college (options: friends, television, Internet, other), a text area for additional comments, and buttons to submit and reset the form. This structure ensures comprehensive data collection, allowing analysis of preferences and sources of interest among prospective students, and helps the university tailor its outreach and campus improvements accordingly .

JavaScript can enhance user interactions by dynamically altering CSS properties or controlling styles upon events such as mouse hovers. For instance, a navigation button can be created in a 'div' containing a link, styled using external CSS. JavaScript can then listen for mouseover events to apply hover-specific styles such as changing the border color, background, and text color, thus providing visual feedback and improving interactivity. This elevates the user experience by making interfaces more responsive and visually engaging. Use cases include navigation menus, form submissions, and multimedia players .

An XML document for representing nutritional information should be well-structured, containing elements for all relevant nutrition facts. For example, it should start with a root element, <nutritionFacts>, containing nested elements like <productName>, <servingSize>, <calories>, <fatCalories>, <totalFat>, <saturatedFat>, <cholesterol>, <sodium>, <totalCarbohydrates>, <fiber>, <sugars>, and <protein>. Each element should encapsulate a specific nutrient value, providing structured, readable data that can be processed programmatically to display, calculate, or compare nutritional information across products .

You might also like