0

I want to make form submission per day will be only 5 submit that any user can click, after 5 click per day the button dissapear and will showing the text. And then the next day the button will be shows up until user clicked 5 times again.

This is my php :

<?php

if(isset($_POST['submit'])) {
$hostname = "localhost";
$username = "root";
$password = "";
$databaseName = "test";



$user = $_POST['user'];
$pass = $_POST['pass'];




$connect = mysqli_connect($hostname, $username, $password, $databaseName);



$query = "INSERT INTO `user`(`users`, `pass`) VALUES ('$user','$pass')";


$result = mysqli_query($connect,$query);




if($result)
{
    echo 'Data Inserted';
}

else{
    echo 'Data Not Inserted';
}


mysqli_close($connect); } ?>

Here my HTML form code

<head>

    <title> PHP INSERT DATA </title>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

<body>
    <form action="index.php" method="post">

        <input type="text" name="user" required placeholder="username"><br><br>

        <input type="password" name="pass" required placeholder="pasword"><br><br>


        <input type="submit" name="submit" value="Add Data To Database">
        //Here my submit button, if row in table "user"in database more than 5 then can automatic dissable
    </form>

</body>

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • 1
    Cool. Can you share what you've tried? – Jay Blanchard Apr 11 '17 at 12:58
  • 1
    [Little Bobby](http://bobby-tables.com/) says ***[your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)*** Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – Jay Blanchard Apr 11 '17 at 12:58
  • 1
    **Never store plain text passwords!** Please use PHP's [built-in functions](http://jayblanchard.net/proper_password_hashing_with_PHP.html) to handle password security. If you're using a PHP version less than 5.5 you can use the `password_hash()` [compatibility pack](https://github.com/ircmaxell/password_compat). Make sure you ***[don't escape passwords](http://stackoverflow.com/q/36628418/1011527)*** or use any other cleansing mechanism on them before hashing. Doing so *changes* the password and causes unnecessary additional coding. – Jay Blanchard Apr 11 '17 at 12:58
  • 1
    This is not the first time u posting this question – Masivuye Cokile Apr 11 '17 at 13:00
  • @MasivuyeCokile yes, i tried to show up my code in this post – Ben Owo Apr 11 '17 at 13:03

0 Answers0