Problems with PHP form

0

I have a form for logging users so that:

<div class="login-form">
   <form action="./compruebaLogin.php" method="POST">

        <div class="container">
            <input type="text" placeholder="Enter Username" name="user" required>
                <br>
                <br>
            <input type="password" placeholder="Enter Password" name="password" required>
                <br>
                <br>
            <button type="submit">OK</button>
        </div>
        
    </form> 
</div>

And I have a file called compruebaLogin.php to which this form is redirected. However, the redirection works badly, since I skipped the error page that I have created by default if the redirection fails. The issue is that this file is in the same directory as the one in the PHP login, the route that I have set is relative, and the visual studio code gives me suggestions, which makes me think that the problem is not the route.

Does anyone know what happens?

    
asked by Sergio Gutiérrez 03.10.2018 в 23:28
source

3 answers

1

Probably your problem is that you are looking in another folder, since normally all the PHP files are worked from a single folder, then in your syntax there is something wrong:

  

<form action=" . / compruebaLogin.php" method="POST">

This is how it should be, removing the "./" because in that case you are indicating that you should look for a directory above, that is, a previous folder.

The other option is that you misspelled the name, because I see that you wrote "checkLogin" with a capital "L", so the name of your file may not have that "L" in uppercase or even "c" "from" check "in reality you have written it as a capital letter, in that case you should write" CheckLogin.php "

    
answered by 03.10.2018 / 23:48
source
1

If you are in the same directory, it would be

           <form action="compruebaLogin.php" method="POST">
           </form>

If your file is in the root and it checksLogin.php it is in a serious folder like this

           <form action="carpeta/compruebaLogin.php" method="POST">
           </form>

If your file is in a folder and it checksLogin.php it is in another folder it would be like this

           <form action="../carpeta/compruebaLogin.php" method="POST">
           </form>

If your file is in a folder and it checksLogin.php it would be in the root like this

           <form action="../compruebaLogin.php" method="POST">
           </form>

Try those forms and tell me how it was ...

    
answered by 03.10.2018 в 23:54
0

If they are in the same directory, try replacing this:

<form action="./compruebaLogin.php" method="POST">

Because of this:

<form action="compruebaLogin.php" method="POST">
    
answered by 04.10.2018 в 01:25