How to Create Newsletter SignUp Form Using jQuery and PHP

A newsletter opt-in form using jQuery, PHP and mySQL. An alternative version using html5 for validation is included in this package. See it here. This is a newsletter sign-up for your web site so visitors can subscribe to your newsletter. The visitor is required to enter a name and a valid email. You may also like How to Create Contact form using Ajax, PHP and MySQL.

PHP and HTML Code

    define('DB_SERVER', "localhost");
    define('DB_USER', "root");
    define('DB_PASS', "");
    define('DB_DATABASE', "ieltsmedidb");
    $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);

        mysqli_query($con,"insert into news (name,email) values('$name','$email')");
        echo "Thank You For Joining Our Newsletter";

        <h1 class="">Subscribe To Get Email Updates Of Our Latest Tutorials On Web Development</h1>
        <form action="" method="post">
                <input type="text" required="" name="user_name" id="user_name" placeholder="Enter Your Name">
                <input type="text" required="" name="email" id="email" placeholder="Enter Your Email Id"/>
            <input type="submit" value="Subscribe" name="submit_form"/>

Leave a Reply

Your email address will not be published. Required fields are marked *