Hi everyone... Well i do have a mysql query in one php page(php_1) & I want to submit the variables to the query in different php page(php_2) via form action but how am I supposed to do it without redirecting to php_1.. All I need is to post the data to the first php page query so that It performs some action over there & thats all... php_1 page :- $query = ("SELECT * FROM state4 WHERE (LONG_HI<'".$_POST['Ymax']."')"); Code (markup): php_2 page:- Ymax<input type="text" name="Ymax" size="15"> <input type=SUBMIT name="submit" VALUE="Submit"></td> Code (markup):
Hi sounds like you want to use Ajax. Ajax allows you to submit information to the server without refreshing the page. You will have to write a Javascript function that submits the form when you click on the submit button. Hope this helped.
You need to submit the data by AJAX calls so that the user stays where they are after submitting the form. Try this: http://www.quirksmode.org/js/xmlhttp.html
Emm it sounds like your making things more complicated then they need to be, is it a problem to put the query on php_2, its the same site right ? Then you just use php function isset
MyVodaFone is right - if there's nothing stopping you from having the form generated by the same php page that processes it, that's a much simpler solution than invoking ajax, especially if you're not familiar with ajax techniques.
well cud u be more specific... I really didn't get u.. yup its the same site.. actually php_1 just generates an image with some overlays from the query && the thing is we do use the Url of php_1 to embed the image in our mapserver framework... So we do always stay on php_2 page & somehow i need to post the variables to php_1 for query purposes....
When you submit your text $_POST['Ymax'] gets populated and your query will run <?php if (isset($_POST['Ymax'])) { $query = ("SELECT * FROM state4 WHERE (LONG_HI<'".$_POST['Ymax']."')"); //.. and the rest of your code from php_1 if needed goes here. } ?> PHP:
You need to post your full codes from both php_1 and 2 here, otherwise we are only guessing how to fix it for you... EDIT: failing that remove the action="php_1.php" from your <form, if you have that.
a example too it's use iframe with target to that frame. <form action="php2.php" target="desc" method="post"> Ymax<input type="text" name="Ymax" size="15"> <input type=SUBMIT name="submit" VALUE="Submit"></td> </form> <iframe name="desc" width="100" height="100"></iframe> PHP:
If it is not a problem to reload the page you are on, then using the isset() function to check for posted variables would work perfectly. As described above, simply use a conditional to look for the posted data and make sure your form action is set to the currect page instead of the second page you were using before. If you would rather submit the form without reloading the page at all, you should look into using AJAX, it will give off the appearance that pressing the submit button instantly completed its task instead of going to another page first. The option is yours depending on how you want your users to see it. I'd have to agree with everyone else though. Using isset() would be much simpler. It is essentially the same method you are using, but your page1 and page2 are merged together.