To answer your question, yes, you are doing something wrong. However, it is easily fixed.
The action on the form is where it submits the form - that is, the page for sending the request. Since you say that your code is "at the top of the page," you will want to submit the form back to its page. Thus, you can either put the full URL of the page into action, or simply leave it blank:
<form name = "tryLogin" action = "" method = "post">
To process the view, PHP is not able to directly call the function from the client code, however you can process the request in a more convenient way of processing requests by sending a hidden field with the current "task" ".
For example, in an HTML form, try adding:
<input type="hidden" name="task" value="logIn" />
Then in your PHP code try adding this:
if (isset($_POST['task'])) { if ($_POST['task'] == 'logIn') { // the user is trying to log in; call the logIn() function logIn(); } else if ($_POST['task'] == 'logOut') { // the user is trying to log out; call the logOut() function logOut(); } }
This code checks if the form has been submitted by checking if the task field has been published. Then it checks the value. If it is logIn , the logIn() function is logIn() . Alternatively, if it is logOut , the logOut() function will be called.
To create a release form, you will correct action accordingly and add a hidden field to that described above, but with the value logOut .