Bladephp: Now with 7+ codeigniter, php, and laravel project 7+ php project From $18/Year From Rs. 1000/Year

How to Prevent Multiple and Duplicate Form Submission Using PHP and MySQL

by
Category:php
php mysql
How to Prevent Multiple and Duplicate Form Submission Using PHP and MySQL

In this tutorial we will show you how to prevent multiple and duplicate form submission using PHP and MySQL. Below you will find two simple tricks for preventing duplicate submissions, you can use either of these or a combination of both. You may also like How to Check UserName and Email Availability From Database using PHP and Ajax and How to generate random username using PHP, Ajax and MySQL.

HTML Code

<html>
    <body>
        <form action="" method="post">
            <input type="text" name="email" placeholder="Enter Email"/>
            <input type="password" name="password" placeholder="********"/>
            <input type="submit" name="submit_data" value="SUBMIT"/>
        </form>
    </body>
</html>

PHP Code

<?php
if (isset($_POST['submit_data'])) {
    $email = $_POST['email'];
    $pass = $_POST['password'];

    $get_user = mysqli_query($con,"select * from user where email='$email' and password='$pass'");
    if (mysqli_num_rows($get_user) > 0) {
        echo "Already Submitted";
    } else {
        mysqli_query($con,"insert into user (email,password) values($email','$pass')");
        echo "done";
    }
}
?>

0 Comments


Html code work in comment box


Related Post