Page 1 of 1

PHP, AJAX, and global variables

Posted: Wed Mar 03, 2010 9:30 pm
by oldsportbiker
Before I start my first Ajax coding effort, I thought I'd confirm my understanding of PHP global variables and sessions. It seems to me , from what I've read, that when I execute a php script from Javascript, that I need to provide that php script with everything it needs as it will not have access to already established global variable or session values, nor will it be able to use the database connection established by the php script that rendered the page from which the javascript will run. Said more simply, I'll have to have every php script that I run from Javascript:
1. start a session
2. establish a database connection
3. logon to the database
4. provide SQL every individual column value that it needs for both select and/or update.

Do I have this right?

Re: PHP, AJAX, and global variables

Posted: Thu Mar 04, 2010 12:25 am
by PHPHorizons
That's pretty much what you need to do.

I design my sites so that the script that handles regular page requests also handles the ajax page requests. I add a variable to the url that instructs the script to omit the header and footer.

Hope that helps.