Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php from

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/style.css">
    <title>PHP Form</title>
</head>
<body>
    <main>
        <?php if ($_SERVER['REQUEST_METHOD'] === 'GET') : ?>
            <form action="<?php htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post">
                <div>
                    <label for="name">Name:</label>
                    <input type="text" name="name" required="required" placeholder="Enter your name" />
                </div>

                <div>
                    <label for="name">Email:</label>
                    <input type="email" name="email" required="required" placeholder="Enter your email" />
                </div>

                <button type="submit">Subscribe</button>

            </form>
        <?php else : ?>

            <?php
            //---------------------------------------------
            // WARNING: this doesn't include sanitization
            // and validation
            //---------------------------------------------
            if (isset($_POST['name'], $_POST['email'])) {
                $name = htmlspecialchars($_POST['name']);
                $email = htmlspecialchars($_POST['email']);

                // show the $name and $email
                echo "Thanks $name for your subscription.<br>";
                echo "Please confirm it in your inbox of the email $email.";
            } else {
                echo 'You need to provide your name and email address.';
            }

            ?>

        <?php endif ?>
    </main>
</body>

</html>
Code language: PHP (php)
Comment

PREVIOUS NEXT
Code Example
Php :: laravel excel set cell height 
Php :: Show all DB Tables in php 
Php :: google fonts change font in echo php 
Php :: wp-config.php repair 
Php :: order by sum() laravel 
Php :: select tag in laravel collective 
Php :: centos :Install or enable PHP gd extension. 
Php :: remove link from product name in woocommerce cart 
Php :: phpspreadsheet edit excel file 
Php :: laravel join with multiple conditions 
Php :: php artisan migrate not working 
Php :: php max value in associative array 
Php :: php repeat string 
Php :: php get all saturdays in a month 
Php :: Carbon Add Months To Date In Laravel 
Php :: woocommerce get user id by email 
Php :: laravel append to model 
Php :: laravel get url without domain in blade 
Php :: php get extension from file from form submit 
Php :: laravel encrypt password 
Php :: store as real file name laravel uplaod 
Php :: php string only letters 
Php :: Call to undefined method IlluminateSessionStore::set() 
Php :: how to create shortcode 
Php :: laravel migration with primary key 
Php :: laravel serve in another port 
Php :: carbon two day ago 
Php :: format time laravel 
Php :: php loop through list 
Php :: where_in codeigniter 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =