Help with PHP Website


#1

Hello, I am working on my PHP final. It is using MVC.
I am trying to get a login page to work. When I click login, it just refreshes the page.

Here is the form:

< form action="…" method=“post”>
< input type=“hidden” name=“action” value=“login”>
< label id=“login-label”>Email:
< input id=“login-input” type=“text” name=“email” required=“required”>
< br>
< label id=“login-label”>Password:
< input id=“login-input” type=“password” name=“password” required=“required”>
< br>
< label> 
< input type=“submit” id=“login-btn” value=“Login”>
< /form>

-root
-index.php
-view
-login.php

I am thinking my < form action="…" method=“post”> is incorrect, but I’m not finding an alternative.

THERE ARE TWO PERIODS IN THE FORM ACTION, FOR SOME REASON IT IS DISPLAYING THREE


#2

action needs to be the link to the page you want to submit the form to:
https://www.w3schools.com/tags/att_form_action.asp

If you want to submit to the same page, just remove action altogether.
If you want to submit to an alternate page, action=“alternate-page.php”


#3

Okay. I think something else may be wrong. Can I DM you?
To go up one directory and use the index.php file, it would be the same as any other time I try to use a file, right?

action="../index.php"

For some reason, it puts three periods instead of two on the forum.


Okay. I know what the issue is. I just don’t how to fix it. I am going to have to read up when I wake up.
It is with the authentication and storing information in the session cookie.


#4

Always try to use full url in action. Define a $base_url variable globaly and use it all over the site. Ex : <form action =”<?php echo $base_url() ?>/index.php”>