On Sat, 11 Jan 2020 11:06:15 +0100, ^Bart wrote:
>> Both of those code should work, but keep in mind that with those forms, the
>> form data will be submitted to the form page, instead of a login page.
>
> I thought to store the login form in the main page and when I clic on
> submit it will show a css login in the middle of the page, is it wrong
> if you'd like to have a good code?
If the login form is in the main page, i.e. in `home.php`, then `home.php`
must be able to serve two versions of the home page for: [1] unlogged-in
users, and [2] logged in users. Also, because your form is designed to be
submitted to `home.php`, then `home.php` must also handles the login
authentication. i.e. it must first check whether client request is using
`GET` or `POST` which is to indicate a normal page request, or a login
request (as per your design).
>> What doesn't work, actually?
>
[snip]
>
> I wrote in the action tag "./home.php", this should be loaded after the
> login, when I use the tag:
>
> <input type="submit" class="button" name="loginSubmit" value="Login">
>
> the action value is not set.
>
>> What are you expecting, and what was the result?
>
> I need to be redirected to the home.php:
[snip]
Keep in mind that your form design is to submit to `home.php`, so there's
actually no need to redirect to `home.php`, because when the form is
submitted, it's already there at `home.php`.
If you think you need to use redirection, then you musn't design the form to
submit to `home.php`. It must be other page. e.g. `login.php` - where it
authenticates the login data. If it's a valid login, then it should redirect
to `home.php`. Otherwise, it should redirect to a login error page, e.g.
`login-error.php`. i.e. each page has its own task.
If you put everything in a single PHP page, then all tasks must be in the
same page. Meaning that the single PHP page must be made smart enough to
differentiate what kind request the client wants, then provide a result
based on the request.