Skip to content Skip to sidebar Skip to footer

Html Form Cannot Post

I am making a user system on a website and I cannot get the form to post to the file. Here is the form in the HTML file:

Solution 1:

You code is working fine.

The problem might be with the file structure. Please check that.

Ex: If your html file in the root folder of your project, Then the userlogin.php files should be there in project_root_folder/test/

So the file structure should be...

Root/
    index.html
    Test/
        userlogin.php

Solution 2:

Code is fine. Just output the values of the variables.

echo$username.'  '.$password;

You can see that the data is being posted.

Solution 3:

Well your code seems to work perfectly fine, maybe the problem is with your testing enviroment, you need solution like XAMPP https://www.apachefriends.org/ to run php scripts on your computer. Other way is to run scripts remotely on some free webhosting that supports php.

If this is not the case then to check if actually data was sent, modify your code this way:

...
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $username = test_input($_POST["usernameL"]);
  $password = test_input($_POST["passwordL"]);
  echo$username."<br/>";
  echo$password."<br/>";
}
...

Post a Comment for "Html Form Cannot Post"