I am trying to come up with a method to differentiate between form being submitted by a unique POST value. While in and of itself this is not that complex an issue my circumstances can lead to their being an issue.
while(!isset($_SESSION['user']) || empty($_SESSION['user'])){
require_once('login_form.php');
}
When a user goes to a page that requires the user to be logged in to view it. If someone lands on one of these pages and is not already logged in I am displaying the login form. The login form’s action is itself, or rather the page being displayed. Now my issue comes when the page being displayed also has a form. I need a method to ensure that the $_POST data from the login form does not make it to the $_POST data from the page’s form. Normally it would not be an issue except when when form inputs share the same name.
I am wanting a way to differentiate between forms using some unique value. I had been thinking about using HTML buttons for submission.
while(!isset($_SESSION['user']) || empty($_SESSION['user'])){
require_once('login_form.php');
}
if(isset($_POST['PAGE_FORM']) && !empty(PAGE_FORM)){
unset($_POST);
}
<form name="PAGE_FORM">
<button valuye="PAGE_FORM">Submit</button>
</form>
I had also thought about doing something like this instead.
while(!isset($_SESSION['user']) || empty($_SESSION['user'])){
require_once('login_form.php');
if(isset($_SESSION['user']) && !empty($_SESSION['user'])){
unset($_POST);
}
}
<form name="PAGE_FORM">
<button valuye="PAGE_FORM">Submit</button>
</form>
Let me know what you think. I would be interested in any other ideas you might have.
Instead of including the login_form, do a http redirect to a seperate login form.