Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Web form to help in creating Jumble puzzles. Create a form that has four input fields named Word1, Word2, Word3, and Word4, as

Create a Web form to help in creating Jumble puzzles.

Create a form that has four input fields named Word1, Word2, Word3, and Word4, as well as Reset and Submit buttons. Create a form processing script that verifies that all four words are entered, that all of them contain only letters, and that all four are between 4 and 7characters long. Once all of the words have been verified as correct, use the strtoupper() and str_shuffle() functions to produce four jumbled sets of letters.

To create the Jumble Maker form:

1. Create a new document in your text editor. Type the declaration, element, header information, and element. The page title should be "Jumble Maker, add to element.

2. Add the following HTML form tags in the body of the document:

Word 1:

Word 2:

Word 3:

Word 4:

3. Save the document as JumbleMaker.html

4. Create a new document in your text editor. Type the declaration, element, header information, and element. The title of the page should be Jumble Maker, add to the ... element.

5. Add the opening and closing tags for the PHP script section in the body of the document:

6. Create a function called displayError(). This function displays the error message, and takes two parameters: $fieldName, which is the name of the field as it appears on the Web form; and $errorMsg, which describes the error for the user. There is no return value for this function.

7. Create a second function called validateWord() below the displayError() function. This function takes two parameters. The first parameter, $data, is a string to be validated. The second parameter, $fieldName, is the name of the form field. The function returns the $data parameter after it has been cleaned up. After validating the user input, use the built-in PHP functionstrtoupper()(Links to an external site.)Links to an external site.andstr_shuffle(Links to an external site.)Links to an external site.() to change all letters to uppercase and shuffle the letters.

8. Immediately after the validateWord() function, declare and initialize a new variable called $errorCount and a new array called $words[] as follows:

$errorCount = 0;

$words = array();

9. Add assignment statements for the $words array variable to receive the output of the validateWord() function for each form field:

$words[] = validateWord($_POST['Word1'], "Word 1");

$words[] = validateWord($_POST['Word2'], "Word 2");

$words[] = validateWord($_POST['Word3'], "Word 3");

$words[] = validateWord($_POST['Word4'], "Word 4");

10. Add a conditional statement immediately after the values of $words have been assigned. This statement will display the total number of errors found or the shuffled words if there were no errors.

if ($errorCount>0)

echo "Please use the \"Back\" button to re-enter the data.
";

else {

$wordnum = 0;

foreach ($words as $word)

echo "Word ".++$wordnum.": $word
";

}

11. Save the document as process_JumbleMaker.php.

12. Open the JumbleMaker.html page in the Web browser by entering the following URL: http://localhost/JumbleMaker.html.

13.Test the form. It should only show the jumbled results if all four words were entered correctly.

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Is having a positive self-concept really all that important?

Answered: 1 week ago