سؤال

I've made a page that logs on, and logs off with forms, php, and javascript.

But the only problem is when you submit the form and the data changes it doesn't update until the page reloads.

<form method='POST' id='login' onsubmit='location.reload();'>
    <input placeholder='Username' type='text' name='user' value='" . $_POST['user'] . "' />
    <input placeholder='Password' type='text' name='pass' value='" . $_POST['pass'] . "' />
    <input type='submit' value='Login' />
</form> 

Notice how the location.reload() is in, but it still doesn't work.

Would there be any possible way to fix this with only JavaScript?

هل كانت مفيدة؟

المحلول

What you want to do is submit the form data asyncronously in the background. JQuery makes this easy... look at this answer, it should get you on the right track.

PHP + Ajax Login

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top