Question

PHP & HTML please Design a web form that contains an input field. The input field...

PHP & HTML please

Design a web form that contains an input field. The input field will accept a list of words that are separated by comma "," . When user hits the submit button, show the results: 1. The count of words. Also show if the count is an even or odd number. 2. The count of words that contains letter 'a' or 'A'.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code

<html>
<title>
Count Words
</title>
<form method="POST">
       <h1> Count The number of words </h1>
<h2>Enters the words seprated by comma</h2>
       <p> <input type="text" name="word" ></p>
       <button type="submit" name="calc">Submit</button>
</form>
</html>

<?php
   if (isset($_POST['calc']))
   {
       $inputWord=$_POST['word'];
       $str_arr = explode (",", $inputWord);
       $wordCount=count($str_arr);
       $countAword=0;
       for($i=0;$i<$wordCount;$i++)
       {
           if(stripos($str_arr[$i],"a"))
           {
               $countAword+=1;
           }
       }
       echo "Input is : ",$inputWord;
       echo "<br>Number of words are: ".$wordCount;
       if($wordCount % 2 == 0)
       {
           echo "<br>Count is even.";
       }
       else
       {
           echo "<br>Count is odd.";
       }
       echo "<br>The count of words that contains letter 'a' or 'A' :".$countAword;
   }
?>

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
PHP & HTML please Design a web form that contains an input field. The input field...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PHP Create an HTML Form that asks for a series of personal information from the user,...

    PHP Create an HTML Form that asks for a series of personal information from the user, and once the user presses the [SUBMIT] button, sends the data to a PHP script that generates HTML code displaying the data entered. The form should have the following fields: First Name (using the text input type) Last Name (using the text input type) E-mail Address (using the email input type) Phone Number (using the tel input type) Date of Birth (using the date...

  • Write a web program to allow the user to sort a list of things. Use HTML...

    Write a web program to allow the user to sort a list of things. Use HTML and PHP. Your input (HTML) should include a text area the user can type in their list. The output (PHP) should be in the form of a table. Use the explode command to break the input up into an array. $list=explode(PHP_EOL, $stuff); Once you have the text into an array, use the sort function to sort it, and then loop through it and print...

  • using PHP.... the code below is a shipping form that has one input text type to...

    using PHP.... the code below is a shipping form that has one input text type to enter the "package weight", destination with a select tag that has the option for New York or Out of State, insurance option with two radio buttons. radio value "yes" has a $10.00 insurance fee, and the no option has no fee, a submit button . all information is within a form with a method ="post" and an action ="<?php echo $_SERVER['PHP_SELF']; ?> <html> <head>...

  • In this assignment you will combine HTML, PHP, and SQL in order to create a web...

    In this assignment you will combine HTML, PHP, and SQL in order to create a web form that allows a manager to add films to the sakila database. You will also create a method to allow the manager to view a list of all films along with their related information, and a list of actors in the movies. Task 1 Create an initial HTML page titled manager.html with 2 buttons. The first button will be labeled “View Films”, and the...

  • 8. Write a script that creates an associative or multidimensional array in PHP a. And displays that array in a table b. Create a form with at least two input fields and a Submit button. c. Write a scr...

    8. Write a script that creates an associative or multidimensional array in PHP a. And displays that array in a table b. Create a form with at least two input fields and a Submit button. c. Write a script that will validate that the user entered data in the input fields and that the fields are not blank when the Submit button is pressed d. And returns the values entered in the input field when the Submit button is pressed.

  • We have to make HTML form with 3 fields, all labeled appropriately: Even or Odd: A...

    We have to make HTML form with 3 fields, all labeled appropriately: Even or Odd: A text field for entering a number. Grade: A text field for entering percentage grades from 0-100. Month: A text field for entering a numeric month value from 1-12. IN PHP :- The script for the first field (Even or Odd) will tell us if the number is even or odd. (Hint: Use the modulus operator.) The script for the second field (Grade) will use...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • Please help with this assignment section A. This question is from world wide web Info Sys Dev. Section A te HTML/JavaSc...

    Please help with this assignment section A. This question is from world wide web Info Sys Dev. Section A te HTML/JavaScript web page called sectiona.html, that has the fpllowing items: a. 2 text items labeled as "CAD Dollar" and "US Dollar", the first(CAD dollars) is enabled with id-"cad", while the later is disabled with id-us" b.1 button named as "convert". functionality: When the user clicks on the button, a JavaScript function named "convert" will be called to convert the value...

  • Design a program using Python and using from flask Import flask that generates a lottery number...

    Design a program using Python and using from flask Import flask that generates a lottery number but in a website.. The program should have an Integer array with 9 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 42 for each element. (Use the random function) Then write another loop that displays the contents of the array. Each number should be displayed as a list, the numbers should be generated...

  • I have created an HTML form. I need to connect this to a database to update...

    I have created an HTML form. I need to connect this to a database to update the phone number in the employee table HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> </head> <body link="#0000EE" vlink="#551A8B" text="#000000" bgcolor="#566573" alink="#EE0000" background="../DOC/brushed-alum.png"> <form method="post" action="phonenumbers.php"> <h1>Update Employee Phone Number Form</h1> <br> <br> <h3>Enter the employee's ID number.</h3> <br> <br> Employee ID Number: <input name="EmployeeNumber" type="text"> <br> <br> <h3>Enter the new phone number</h3> Phone Number: <input name="OfficePhone" type="text">...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT