PDA

View Full Version : PHP/Ajax



dewey
June 26th, 2007, 02:07 PM
Hey everyone,

I'm really interested in getting into some Ajax type stuff with PHP. Nothing too serious to start, but all my experience with Ajax has been with Portlets so I am not sure how different it is with PHP.

What I want to start is something simple, maybe just a login screen that can check a username and password given against records in a database, if they exist then log the user in (basically just put him into a new page) if not then just put an "invalid username/password" message under the button...

This seems like the easiest way to get started, and if anyone would be willing to help me out, it would be much appreciated.

Thank you,

--d

evildrummer
June 26th, 2007, 02:25 PM
Ok first you need the main components:
1) A login page with a div that when it has data in displays like an error message
2) The whole page surrounded by a div that can be replaced with new page
3) A PHP page that can process the requests and say yes or no to correct login

dewey
June 26th, 2007, 02:55 PM
Well, yea... I understand that part, I mean I 'get' PHP, but what I am unsure of is the making of AJAX calls so that I can check to see if the username/pass are actual values in the DB... that's where I get concered... how do I call the PHP function with my javascript AJAX call?

eirche
June 26th, 2007, 04:20 PM
how do I call the PHP function with my javascript AJAX call?

no you don't do that.

to understand what ajax does, http://w3schools.com/ajax/default.asp

evildrummer
June 27th, 2007, 12:26 PM
What I do is give PHP some variables, normally they are, 'type' and 'data'.

Then PHP reads type so it knows what it is checking then it reads data and checks it then returns data in an easy to modify way.

Also are you sure you want to learn the actuall AJAX code, you could just use a framework for the AJAX calls which I find ALOT easier