162k views
1 vote
Create a page using PHP for a business website that will ask the user to enter his or her name into text boxes and will display a welcome message that uses the user’s name.

User Zeyger
by
7.3k points

1 Answer

1 vote

Answer:

1 <?php

2 if (isset($_GET["submit"])) {

3 echo "Welcome " . $_GET["name"];

4 }

5 ?>

6

7

8 <form method="get">

9 <input name="name" type="text" placeholder="Enter your name"/>

10 <button name="submit" type="submit">Submit</button>

11 </form>

12

13 <?php

14 ?>

Step-by-step explanation:

Lines 1 - 5 check if the user has clicked on the submit button.

If the button has been clicked the a welcome message is

shown.

Lines 8 - 11 create a form to hold the text box and the submit button

Give the form a method attribute of value get [Line 8]

Give the input field a name attribute of value name and a

placeholder attribute of value Enter your name [Line 9]

Give the button a name attribute of value submit and a type

attribute of value submit [Line 10]

PS: Save the file as a .php file and run it on your server. Be sure to remove the line numbers before saving. A sample web page is attached to this response.

Create a page using PHP for a business website that will ask the user to enter his-example-1
User Pmkent
by
8.1k points