112k views
2 votes
Ex-1 Create a feedback form which contains a drop down list, three text fields, a radio button group, a comment field, and a submit button. When user click the submit button, your system willecho back whatever user entered.

1 Answer

6 votes

Answer:

<form action="my_feedback.php" method="post">

Name:

<select name="title">

<option> Dr. </option>

<option> Mr. </option>

<option> Mrs. </option>

<option> Ms. </option>

</select>

<input type="text" name="name" required="required"> <br/> <br/>

Email Address: <input type="text" name="email" required="required"> <br/> <br/>

Phone Number: <input type="text" name="phone" required="required"> <br/> <br/>

Rating...

<input type="radio" name="rating" value="excellent"> Excellent

<input type="radio" name="rating" value="okay"> Okay

<input type="radio" name="rating" value="boring"> Boring

<br/> <br/>

Comments: <textarea name="comments" rows="4" cols="15"> </textarea> <br/> <br/>

<input type="submit" value="Send My Feedback">

</form>

PHP FILE:

<?php

# form method is post so that's why $_POST is used and the nae used with the $_POST in the [] parentheses is the name

# attribute of the html tag.

echo "Thank you, " . $_POST['title'] . " " . $_POST['name'] . ", for your comments. <br/> <br/>";

echo "Your email address is " . $_POST['email'] . " and your phone number is " . $_POST['phone'] . "<br/> <br/>";

echo "You stated that you found this example to be '" . $_POST['rating'] . "' and added: <br/>";

echo $_POST['comments'];

?>

Step-by-step explanation:

User Lyndonna
by
4.8k points