PDA

View Full Version : php file result not displaying in new window opened


lizzy
05-29-2008, 09:19 PM
Hi there, i would appreciate it so much if somebody could please help me, i have been struggling on this problem for ages and i am not able to resolve it.

i have 1 html file (main page) this files has 4 forms, each form 1 after the other. the separte forms on the main page are used to post data to php files via text boxes and submit button.
for example i have a php file called availablewards, which takes the input from the html file and performs a query inregards to the input given and displays the result of the query.
the html file is like this
<form name ="ward" method= "post" action="availableward.php" >
this form all so has a submit button that opens up the availablewards.php when clicked on opens the php file in separate window.
<input type="submit" value="Find ward" onclick="window.open('http://localhost/availableward.php')"

however the problem is the new window that opens does not show the query result, it shows blank. the result is diplayed in the main window, main window changes loction to availableward.php. i need for the main window to stay the same and for the query result to show in the newly opened window when the submit button is clicked on.

i have also changed the submit button as below, this prevents the main page from changing but does not show the availableward.php file results in the new window.
<input type="submit" value="Find ward" onclick="window.open('http://localhost/availableward.php');return false"

All help is appreciated. thank you

derzok
05-29-2008, 09:44 PM
I think this is the problem:

the onClick option is causing it to ignore the action= value. It's just going straight to that page without submitting any data. Instead you want it to just submit the data. The page that handles the submitted data should:

1) insert the data
2) display the data OR send you to a page that can display the data.

You can forward users with the header() command in PHP (as long as you haven't sent out <head> tags yet) or with javascript.

mlseim
05-29-2008, 09:58 PM
Would it be possible to have everything stay on
one page only (no other pages)?

Example,
Your main page has the 4 forms on it.
If you do something on form1 and submit, it does
its thing and redisplays the main page with the
results, along with the 4 forms.

The results for form1 would be part of form1.

So every form calls the main page and all of the
PHP stuff is on that main page. It just displays
results and queries depending on which form
is submitted.

The user would not have to deal with other
open windows, which could open on top or
below depending on their browser or computer.

I think it would be less confusing for the user,
but then again, we can't see the main page,
and the other pages (not knowing how elaborate
your forms really are).

This would be done using PHP ... although I could
see a use for AJAX, but that is a lot more work.

If you can't post the 5 files (main, window1 ... window4)
on here (sensitive info), PM me with a link that I can
look at.

lizzy
05-31-2008, 12:43 AM
Hi there i managed to get it to work. thanks for replying