Page 1 of 1

PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Fri Jul 25, 2008 3:01 pm
by s.squared
Ok, I'm trying to make a webpage and this is what I would like to do:

-I would have a frameset that loads an html page in one frame and a php page in another (hidden) frame
-The user would enter some information in a form on the html page
-A php page would be loaded into the hidden frame and would get the information from the html form
-the php script would process the information and return the information to the html page (or make the info available, perhaps in a hidden form, so that a javascript script could get the information)

I'm wondering what the best way is to get the information to the php script. I could get the data from the form with javascript and then use javascript to load a url into the other frame with the variables attached (parent.frames[1].document.location='phpfile.php&var='+var). But I would like to know if there is a different way to do it that would perhaps be better? and if i use the method i just stated, how would I get the variable from the url?

thanks for any help!

Re: PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Fri Jul 25, 2008 3:45 pm
by Dynamis
I don't know how this is going to hinder your idea, or maybe just set it back, but it is not wise to use frames anymore. They are deprecated.

Re: PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Fri Jul 25, 2008 3:47 pm
by nowaydown1
I'm not sure what your goals are exactly, but this sounds like a really roundabout way of doing things. Is there a reason you dont want the PHP script to just process your form results? From what you did describe though, I would take a look at AJAX technology. It sounds like what you want, without all the hidden frame crazyness.

There's plenty of PHP + AJAX tutorials floating around. Take a look at see if that makes sense for your needs.

Re: PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Fri Aug 01, 2008 3:10 pm
by s.squared
well basically what I want is to be able to have interaction between Javascript and PHP... but Javascript is clientside and PHP is server-side so I'm trying to figure out how to do it. What I want to be able to do is get input from the user and put it into MySQL. (I don't know anything about AJAX... I will look into it)

Thanks for your help!

Re: PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Fri Aug 01, 2008 6:04 pm
by omniuni
Using javascript when you don't need it is generally a bad idea, unless it's COMPLETELY for fluff.

However, if you insist upon using JS, then AJAX is the way to go. Honestly, though, your best bet it likely just to submit the form as POST data, and allow the page to refresh and enter it into MySQL. It's simple, and as compatible as you're going to get with lots of browsers.

Re: PHP, Javascript, Hidden Forms, and Hidden Frames... help!

Posted: Sun Aug 03, 2008 11:08 am
by pkbruker
1. Stay away from frames. They're the work of the Devil!

2. If your form is not that big, let the page reload for PHP to check if the values are correct. This is a simple and easy way of doing it.

3. If the values in the form can be validated without data from the server (i.e. you don't need to compare inputed values to a database), simply use client-side Javascript to validate the form values.

4. If #3 is not possible, look into Ajax as already noted. But, if your form is not that complicated, take a look at the XMLHttpRequest() function, it might provide a simple solution for your problem.