...

View Full Version : Referencing PHP inside of Javascript (or the other way around)



ajetrumpet
09-11-2009, 06:14 AM
all,

i have a large PHP script that gives me a report online. i need to reference a couple of controls on the that are on the page while the script is running. example, I have these two inputs:
<input type="text" name="username" id="username" />
<input type="text" name="Password" id="Password" />i really need to reference those value in the PHP I wrote, but I just can't seem to find a way to make it work. the page has a PHP extension. i'm also open to ideas of writing the PHP inside of a JS function, if it's even possible. ideas anyone? thanks!

Zangeel
09-11-2009, 06:44 AM
So basically you need to reference the values a user inputs in those text boxes, without the use of forms? Or am I missing something?

ajetrumpet
09-11-2009, 06:57 AM
So basically you need to reference the values a user inputs in those text boxes, without the use of forms? Or am I missing something?

no you're not missing something. i wasn't clear though about what I want. basically I want a login form to validate the identity of the visitor before they view the tables that the PHP writes to the webpage. does that make sense?

so in short:
*if login valid, form disappears, script runs and log is written
*if login invalid, message and clear the form

Zangeel
09-11-2009, 07:01 AM
If you know your way around javascript most of that is easy, referencing a php script with javascript is AJAX. So you can grab the values they input, check if the login is valid, do any other voodoo magic you want in your php script, and then send the data back to the page you're on.

I explained the ins and outs of ajax here: http://codingforums.com/showthread.php?t=176200

Scroll down to my long post.

Is that something you need? AJAX?

ajetrumpet
09-11-2009, 07:04 AM
If you know your way around javascript most of that is easy, referencing a php script with javascript is AJAX. So you can grab the values they input, check if the login is valid, do any other voodoo magic you want in your php script, and then send the data back to the page you're on.

I explained the ins and outs of ajax here: http://codingforums.com/showthread.php?t=176200

Scroll down to my long post.

Is that something you need? AJAX?

if this logic is true.....AJAX = PHP inside JAVASCRIPT....then yes, AJAX is exactly what I need to learn. why?

Zangeel
09-11-2009, 10:39 AM
AJAX Is basically referencing a script or external page while running another script (the page you're on) so you can pass variables to php, and return a result without changing a page. The basics are in that post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum