0

I am trying to add a login scroll-down window in my page. The window itself works fine (http://pasionesargentas.webatu.com/test4.php), but now I need some help- I need an approach as to how to integrate the new input form to my actual log in system. In the scroll-down window you see the two fields (username and password) and the submit button. But the actual login system I have a totally new window (http://pasionesargentas.webatu.com/signin.php) where I do the whole checking and session start. I could probably merge the php login code with the scroll-down window, but I would not prefer to do that since that scroll-down window is in the header and I wouldn't like to run the check every single time a page (with the header) is opened. I am really afraid of not being understood so here I am adding some more lines of the same:

I have a javascript scroll down window with two fields (u/n and pass) and a submit button but I don't know how to check those values with the database so I can start the session for that user.

1 Answer 1

2

You use AJAX. I'll just write my code using the jQuery library, as that is what I am familiar with.

When you press the Submit button on your login form, the browser sends a POST request to your login PHP page, which processes the request and sets up a session for the user.

You can emulate this behavior with JavaScript:

$.post('login.php', $('#id_of_login_form').serialize(), function(data) {
  alert('You have been logged in!');
});

This code will log you into your website from a different page.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, Mr Blender. I changed the form action to login.php and for some reason it worked. I don't really know why since the login.php IS a form, but it validates it right. Sorry but I'm still kind of dumb with object oriented languages. THANKS
That works too (a better solution than mine, IMO). Either way the browser sends the POST to the login.php page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.