Sunday 15 June 2014

login - Troubles moving errors from one page to another PHP -


I am following PhpAcademy's tutorial on creating a login system, and I am very new to all of this. Instead of creating a widget as it did, I created a whole page for the login form, called signin.php, and a verification page called login.php. The action of the forms is login.php, this is the file, and I have an array errors [] is stored in a php file on all pages, whenever I get an error, then I attach it to a new error, all this is fine But now I want to show my errors below the form on the login page, how can I do this? Right now, errors are only visible in login.php. I have tried to send errors using the header, which did not seem to work, and I try to print errors of the errors by outputting the array there (Because it is global), but nothing like this seems to be printed. What can i do

Global does not mean that it is global on all pages. Global is only global for the current page. If you want to keep data between pages / redirects, you need to pass the data in the URL (i.e., signin.php? Error = invalid user name and password ). I do not like this method because you need to clear the error message and make this URL ugly.) Or you have to store it so that you can get it on the next page. The easiest option to use $ _SESSION is an example:

login.php

    

signup.php

  & lt ;? Php session_start (); // ... if (isset ($ _ session ['errors']) {// it displays some errors that display better print_a ($ _ session ['errors']); // Remove the error from the session so that we do not set it twice ($ _ session ['Errors']); }    

No comments:

Post a Comment