Create A Web Page That Collects User Information Using A Form And Displays It When The User Clicks The Submit Button

0

Create a web page that collects user information using a form and displays it when the user clicks the submit button.


Create A Web Page That Collects User Information Using A Form And Displays It When The User Clicks The Submit Button


PROGRAM
<!DOCTYPE html>
<html>
<head>
    <title>User Information Form</title>
</head>
<body>
    <h1>User Information Form</h1>
    <form method="post">
        <label for="name">Name:</label>
        <input type="text" id="name" name="name" required><br><br>
        <label for="email">Email:</label>
        <input type="email" id="email" name="email" required><br><br>
        <label for="phone">Phone:</label>
        <input type="tel" id="phone" name="phone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required><br><br>
        <input type="submit" name="submit" value="Submit">
    </form>

    <?php
        if(isset($_POST['submit'])) {
            $name = $_POST['name'];
            $email = $_POST['email'];
            $phone = $_POST['phone'];

            echo "<h2>User Information:</h2>";
            echo "Name: " . $name . "<br>";
            echo "Email: " . $email . "<br>";
            echo "Phone: " . $phone;
        }
    ?>
</body>
</html>

OUTPUT

Create A Web Page That Collects User Information Using A Form And Displays It When The User Clicks The Submit Button


Explanation
This script includes a form that collects the user's name, email, and phone number. When the user clicks the submit button, the form data is sent to the same page and processed using PHP.

The isset() function is used to check if the submit button has been clicked. If it has, the form data is extracted using the $_POST superglobal array and displayed on the page using echo.


❤️ I Hope This Helps You Understand, Click Here To Do More Exercise In PHP Programming.


Post a Comment

0Comments
Post a Comment (0)