PHP WordPress issue with isset() Function

All this code is written on the same page

 <form method="post" action = "" >
    <p> Username: <input type="text" name = "username" /> </p><br>
    <p> Password: <input type="text" name = "password" /></p> <br>
    <input type="submit" name="submit" value="Register" />

 if(isset($_POST['submit']) && !empty($_POST['submit'])) 
   $username = mysqli_real_escape_string($conn, $_POST['username']);
   $password = mysqli_real_escape_string($conn, $_POST['password']);
   $sql = "INSERT INTO Duomenys (Username, Password) VALUES ('$username','$password')"; 

The if(isset($_POST['submit']) && !empty($_POST['submit'])) does not trigger, it sends the account’s details to my database everytime I refresh the page. What am I doing wrong?

Note: Still learning PHP and WordPress

Read more here: PHP WordPress issue with isset() Function

Leave a Reply

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