Ajax login form (PHP & Javascript)
on Saturday, September 22nd, 2007 at 8:10 pmOk, here’s another AJAX login form example…
In this example I am using 3 javascript files, 2 php files and 1 stylesheet.
click here: http://mazesolutions.me/demos/ajax2 for the demo
click here: http://mazesolutions.me/demos/ajax2/ajax2.rar to download the files
Brief description:
_ajax.new.js: is the main ajax class. I have already explained this class here
_formdata2querystring.js: used for posting the element of a form
_applogin.js: specific ajax class to handle the login form
index.php: simple login form
style.css: simple stylesheet
If you like it digg it here
Next post will be a tutorial on how to make it
Stay tunned …
//Jo
Peace
168 Comments »
I’m trying download the source files, but every time I try I get a page with a bunch of nothing on it.
D.Peterson: Try to right click on the file then Save As.
Its working fine here with me
Arnulfo Arias: The login form will redirect you to welcome page when the login is correct.
[...] i noticed a new referral in my referrals list. Anyway it seems that an italian blog has mentioned my Ajax login form (PHP & Javascript) post in an article of his. The article can be found [...]
To FARAWAY:
The italian article talks about “Modern (Web 2.0?) ways of dealing with HTML Forms”. The article itself is a sort of link collection.
[...] Ajax login form (PHP & Javascript) – FARAWAY (tags: ajax php authentication form javascript login webdev webdesign development web) [...]
hi matej, can you please tell me what browser you are using ? and if you have javascript enabled or not.
the password should be : iwannalogin ( no spaces and case sensitive )
the email should be: email@gospam.biz
kind of ugly that the password is being send in the post.
you should encrypt the password before sending it with js to php and then decrypt it again with php.
Yeah you are right,
I will do it today and update the script… thank you mister p
When i submit i’ve always this message “going somewhere ?”
i don’t know why please help me
Hi jb
in the file js/_ajaxlogin.js
go to line 105, it should be:
self.ajax.doPost(‘ouf.php?action=login’, postData, self.handleLoginResp);
In your case i think it is not
check it and if u need anythg more reply
Thank’s but i’ve always the same problem
go to
http://notedeletudiant.com/ndl/test2/testlogin/
Hi jb
Im sorry for this error, you should add this line at the beginning of ouf.php ( before switch($action) ).
###
$action=trim($HTTP_GET_VARS['action']);
###
or re-download the files… i fixed them
Let me know if that worked for you
It’s not working on IE, the submit button never gets activated… any ideas?
TheMan: Can you please tell me what IE version you have ?
I tested it on IE 6 and it seems to work.
Make sure you do not copy and paste the password, because then it wont work.
Or better yet, upload somewhere on the net so i can see it
help for this error!
self.form.Pass has no properties
[Break on this error] self.form.Pass.value = ”;
or something i dont understand…got the same error that max…text “welcome.html” appears in the box…
can this be due to the fact i work on local server (easyphp) ?
Could you please help me with one thing ? I need the LOG-OUT thing. I made the login case at ouf.php to save the sessions, for keeping user on the page if he will try to refresh the page, but now i dont know how to create an AJAX Request for my ‘LOGOUT’ case, which i made and filled with session_unset(); session_destroy(); and etc. Could you please help me with this ? Best reguards, Tiesto )
Hi Dj Tiesto
All you have to do is add the javascript function in js/_applogin.js that will call your case at ouf.php
the function can be smthg like this:
this.a_logout(){
var self = Login;
self.ajax.doGet(‘ouf.php?action=logout’, ‘text’, self.handleLogoutResp);
}
then implement the handleLogoutResp function
this.handleLogoutResp = function(str) {
var self = Login;
var respArr = str.split(‘,’);
var respType = respArr[0].toLowerCase();
var respMsg = respArr[1];
var respSes = respArr[2];
if (respType == ‘success’) {
location = respMsg+’?'+respSes;
}
else {
self.showErrorPrompt(respMsg);
}
}
Finnally add this to the end of the _applogin.js
document.getElementById(‘logout_id’).onClick = Login.a_logout;
where logout_id could be the id of ( Logout
If you need anything else tell me.
By the way can I see the website where u implemented my ajax function ?
I agree, multiple users and the ability to change where the user ends up after hitting submit depending on their username would be great!!!
I will do second version of this login form and include the following:
1- logout
2- session/cookie for each multiple user
3- ability to redirect ppl depending on the user to a specific page
Sir, I want to create a login form, that will differentiated between the Administrator and User with their Authorty
Sir, I aslo have a problem to develop a page of on line exam, So that the User can not make copy of this form
It’s a good idea BUT…
You got some wrong things in the code.
1. you can type any email that you want
2. you don’t have to write the whole email just a letter or two.. not even the @
3. you can login how ever you want to.. you just ned the a correct password. It has nothing to do with the email.
[...] Here’s another AJAX login form example using php, javascript and css. http://joeabiraad.com/ajax/ajax-login-form-php-javascript/89 [...]
Hi there,
Just came across this and whilst it seems to work okay if you click the button, if you press return whilst in any of the fields it will let you in no matter what you type into the fields.
Just thought you should know.
Best wishes,
Mark
This login form does not register any session/cookie.
You will have to this yourself
t’s a good idea BUT…
You got some wrong things in the code.
1. you can type any email that you want
2. you don’t have to write the whole email just a letter or two.. not even the @
3. you can login how ever you want to.. you just ned the a correct password. It has nothing to do with the email.
——-
Just change:
if ($password == $good_pass){
To:
if (($password == $good_pass) && ($email == $good_email)){
[...] Ajax login form (PHP) [...]
IT’S VERY NIC BUT I FOUND JS ERROR ON IE 7 IF U ENTER INCORRECT EMAIL AND PASSWORD
BUT OVERALL IT’S VERY GOOD EXCELLENT JOB
REGARDS
SALIK AHMED
When I put de User & pass text “welcome.html” appears in the box. I need to redirect another page or addresscom. Can u help me?
hi, it’s no work
same error going somewhere ?
ouf.php ( before switch($action) ).
###
$action=trim($HTTP_GET_VARS[’action’]);
### this line its ready
i am not sure what happend can u help me please
I uploaded all the files into the server it does not bring me to the welcome.html page. and i was still in the index.php page with the message display ‘ going somewhere ?’ but when i test it using localhost, it works. can you help me out with tis problem?
[...] Ajax login form (PHP) [...]
Hi, it wont load at all, in firefox it loads the message in the top box, but i get the error going somewhere? latest version used, in ie though, nothing, no messages nothing.. please help? Thanks
Hi everone,
I have a question.
Could you please help me ?
How can a server understand when lots of users login simultaneously ?
I am working with PHP but I cant write a script for this.
thanks from now
Hi, Thats beautifullogin u implemented. I had to remake my login using ur code. but apparently the ajax part doesnt work. i have other works in ajax and they work fine. this is how it is now. wen i hit the submit button it starts loading the whole part no ajax working. and am using fire bug the error there is
self.form has no properties
http://127.0.0.1/_applogin.js?2122778914
Line 76
what could be there problem. its really frustrating me. thanx
When I am downloading it, then ajax2.rar gets download but when I open it there is nothing in it.
Please help me. and send me the files to my email
thanx
great form.
but i dont understand how t use the javascript stuff.
wont open on my pc.
where do i put it in my site?
This is a nifty script
Well, it’s asked before. Do you know if it’s easy to use for a multi-login purpose. So integrate a variable which identifies the loginform.
That should be really great!! Hopefully someone can help me with this.
Thx!
Nice script, it was just what I was looking for, however, I noticed once you get to the welcome page you can bookmark it and return later bypassing the login. Is there a way to make someone always login?
nice cript. but what you do when you get to the page . how can i protect the pages and the files in the in there , so users MUST login to see the pages ?
thanks
jeff
[...] Ajax login form (PHP) [...]
Hi… good contribution.
Is there a way I can redirect to a url which has been typed in earlier, rather than to the welcome page.
Many thanks.
to hone
self.form.ChangeAlert.checked is null or has no properties
in _applogin change uncoment //self.enableScreenReaderFeatures();//Joe
Hello!
I wondered if you planned a review & update of that script. It’s wonderful that way, but some options which are probably easy for any experienced PHP/MySQL coder would be awesome…
-Register form
-MySQL for accounts storage
-A mini admin panel allowing to add/delete accounts and to modify informations
-Sessions: to remember when the user has logged-in.
That’s all. Also, you promised us a tutorial and I haven’t seen it… is it still planned?
Regards,
Fox
Also, maybe a bit more secured features…?
[...] 23. Ajax login form ( [...]
Hi,
i have this message:undefined, and i don’t know why. Help me please.
Adress of website: http://jbv.ced.travel/connexion_utilisateur.php
hi,
i need to refresh two / {whatever is possible} at one time by clicking a button but not refreshing the other fields of a form, nor by posting other fields , it should just work as the captcha refresh works, and refreshes the captcha code by interfering the rest of the fields. A help will be highly appreciated and thankful.
[...] 23. Ajax login form ( [...]
hi,
i am trying to use the script on one of my site i was trying without chaining any of the script but still i get the error
“going somewhere ?”
i have this line in code as mentioned above
$action=trim($HTTP_GET_VARS['action']);
and this below line also
line numner 105, it is :
self.ajax.doPost(’ouf.php?action=login’, postData, self.handleLoginResp);
still i get the error can u help me please
How to “enable” the submit button “only” once all validation completes?
If the validation is not complete, no submit.
Is it possible and how to enable this function?
Cheers
Forgot to add.
I have used this to validate against the database by means of username, email address and would only like to allow the submit button to be available or enabled once the validation is happy:)
Cheers
[...] Nome: Ajax Login Form Descrição: Verifique a autenticação de login e senha via Ajax Download: http://joeabiraad.com/ajax/ajax-login-form-php-javascript/89 [...]
[...] Alternatively you can also use them for login forms, saving the user a trip back to the page they were at. FARAWAY [...]
The login.php file in the current rar file seems to only be a partial file. The file ends with ‘<’.
[...] joeabiraad.comFormat: AJAX JavascriptDownload – Preview Diese Icons verzweigen auf soziale Netzwerke bei denen Nutzer neue Inhalte finden und [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
[...] Ajax login form (PHP & Javascript) [...]
[...] Ajax login form (PHP & Javascript) [...]
[...] Ajax login form (PHP & Javascript) [...]
hello,
when i tried to run i got this error..
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required ‘/var/www/apache2-default/ajax/login1/index.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in Unknown on line 0
please help me soon
[...] 1.2 Ajax login form (PHP & Javascript) [...]
This works beautifully…locally (XAMPP). However, on my host, it doesn’t, and returns the “going somewhere?” response. So for those with the “going somewhere?” error, it may be the way the Ajax is handled on your host.
The solution to my “going somewhere?” error was that my host ignores $HTTP_GET_VARS. Changing that to $_GET resolved the issue.
[...] 1.2 Ajax login form (PHP & Javascript) [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
Hey, awesome work.
Is there any way to hide the password and login names in ouf.php, if someone wanted they could check the source of the index.php, then download the accompanying js files and figure out it’s routed to ouf.php and then they download ouf.php and then whala, login and password. Is there a way to remove this capability?
I like what you’ve done, taught me quit a lot so far.
Fantastic script Jo. Had to tweak a few codes to make it work for us, but it works wonderfully.
[...] Ajax login form ( [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
[...] Ajax login form (PHP) [...]
Hello webmaster
I would like to share with you a link to your site
write me here preonrelt@mail.ru
how to access database values in ouf.php
i tried to compare user name and password from database
its not working
[...] login form (PHP & Javascript) [...]
[...] Ajax login form (PHP & Javascript) [...]
I’m just downloaded the zip file and threw it on the wamp server as is and when the index page fist launches, i get a “less then” operator in the lower left hand corner which indicate to me that there is something off with the code. But I went ahead to try to log in with the hint you provide but nothing registrars in the box. Anyone else experience this? Also i see in the index page there’s 2 js code that have ?” withing the call but should it have <?php in that call?
[...] Site: http://joeabiraad.com/ajax/ajax-login-form-php-javascript/89 [...]
Hey there!
So far, your script is working really well for me.
I am having a huge problem that is driving me up the wall, though.
When submitting my form, the link in which I would like to be redirected to is shown. My guess is it’s a problem with the server on handling everything, but I really need the redirect to work. I’ve tried other ways around it, but since the responseFormat and whatnot are all set to text/XML/object and I can’t seem to get it to anything with HTML- I can’t get a redirect at all. Please please please help me out as quickly as possible!
-Alexander
[...] Ajax login formA very simple ajax-based login form. [...]
[...] Ajax login formA very simple ajax-based login form. [...]
nice tutorial its work but why i’m type welcome not index thats show up in my browser. the page not protected how to protect welcome page
[...] Ajax login formA very simple ajax-based login form. [...]
[...] Ajax login formA very simple ajax-based login form. [...]
[...] Ajax login form (PHP & Javascript) [...]
[...] Ajax login form A very simple ajax-based login form. [...]
I Have One Problem!!!!!!
I have done “Check Availability of Email”program but my Problem is when I click on Check Availability Button My Form is Submit Why?
i have not click on submit button Please help me
[...] 23. Ajax login form ( [...]
[...] Ajax login form A very simple ajax-based login form. [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
[...] 1.2 Ajax login form (PHP & Javascript) [...]
yap. its a great login script i appreciate your efforts.
Thanks!
Atiq khattak SWE EsolPK
Thanks Man! That is a very nice script.This is also a php-ajax script,It is kinda easy to use http://www.phpstring.co.cc/ajax-login-module/
[...] noticed a new referral in my referrals list. Anyway it seems that an italian blog has mentioned my Ajax login form (PHP & Javascript) post in an article of his. The article can be found here. So the reason i am writing this post is [...]
noticed a new referral in my referrals list. Anyway it seems that an italian blog has mentioned my Ajax login form (PHP & Javascript) post in an article of his. The article can be found here. So the reason i am writing this post is [...]
Is it possible to have multiple users with different passwords and a different message to be displayed for each user?
Is it possible to have multiple users with different passwords and a different message to be displayed for each user?
Is it possible to have multiple users with different passwords and a different message to be displayed for each user?
Not working anymore in Google Chrome version (5.0.375.55 beta). Submit button is inactive..
Is it possible to have multiple users with different passwords and a different message to be displayed for each user?
RSS feed for comments on this post. TrackBack URL