Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Currently what I wrote does like this: when you click the button (for example) it submits a form to a PHP document, which in tunr executes a file on the server (using EXEC)
The problem is that after you submit the form, the page must reload, and thats not neccessary here at all- as a matter of fact, no response is neccessary whatsoever here... Thats why I'm looking at XML in order to hoefully be able to accomplish the same thing (click POSTs to a PHP which runs a file on the server) but in a one-way type of thing where there is no output or response.
Now I've looked all over and could not figure out how to do this! If someone knows how to do this, I'd greatly appreciate if you could show me an example...
Here's what I have right now:
This is one HTML file with JavaScript which submits a form to the second frame of a parent window which is a PHP:function keypress()
{
var keypress=window.event.keyCode;
if (keypress==38) {parent.right.document.keyform.key.value="upkey";}
}And this is the PHP file:
<HTML>
<HEAD><form name="keyform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="key" value="null">
</form></head>
</body>
<?phpif (isset($_POST['key']) && $_POST['key'] == "upkey") {
exec("beepA.exe");
}?>
</html>
Any help would be very helpful!
Thanks,
Larry

how about you give us an example of what you want. the question that you're giving is undefined. so just simply give us an idea of what you want and i could probably think of something for ya... a couple problems that you got there
<HTML>
<HEAD><form name="keyform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="key" value="null">
</form></head>
</body>
<?phpif (isset($_POST['key']) && $_POST['key'] == "upkey") {
exec("beepA.exe");
}?>
</html>
the form is supposed to go in the body, there should be a opening body tag and what the heck goesif (isset($_POST['key']) && $_POST['key'] == "upkey")
mean?
it's asking that if the form is submited and if 'post key' = "upkey" then it exec's beepa.exe... well in the form 'post key' is assigned to "null" after the form is submitted.
maybe that was your problem? just giving a few ideas
FBI Agent
AIM: EliteAssassin187

There are two ways.
One way is the hidden frame hack (now "technique"), which can be implemented more cleanly in something like OpenThought.
The second way is to use the XMLHTTPRequest Object. This is similar to a DOM 3 standard. I also have heard Google uses it in several places, but that is unconfirmed.

Yes exactly- right now I set the second frame to basically invisible (thats the only solution I could think of...) but then I bumped into this HTTPXMLREQUEST and it looked like it could do it, but after reading that page that you linked and others like it, I still cannot figure out how to implement it into this case...
Can you just give me example of how it might be implemeted into this kind of thing?
Attn. FBI AGENT- I dont know how it works- but it works in the end of the day. I played around and the thing simply works, so that isnt really the problem. The problem is that there is a delay from when the form is submitted until the file is actually run (very small delay, but running it from the local computer I was expecting that there should be virtually no delay at all...), and I was thinking that it may be because Apache has to compute a response page or something so I was hioping that using a 'one way' request could make the response time quicker...
I just want to add that the code above is not the whole thing but only part of it- basically the main part that does the job. (Ie. I didnt paste the master HTML that designates the frames or the full HTML of the other ones... only the basic point of what its supposed to do...)
Thanks,
Larry

Here's an incomplete, untested example. Let's assume you used javascript to grab the form variables.
//open the object
var NewObject = new XMLHttpRequest();/*configure message to call process.php and send POST data... the flag set as true is for an asynchronous connection*/
NewObject.open("POST", "processinfo.php", "true");//now we send POST data
//Note the formatting
NewObject.send("Variable=value&Var2=value2");I used the send() method for the POST data, not the setRequestHeader().

If I'm understanding this correctly, that script would POST as soon as the page loads, correct? So I'd have to place an 'if' somewhere if it were to be triggered by an event...?
Thanks

I've tried to implement it but it doesnt seem to work here- this is the code:
<html>
<head>
<script type = "text/javascript">var NewObject = new XMLHttpRequest();
function keypress()
{
var keypress=window.event.keyCode;
if (keypress==38) {NewObject.send("key=beep1");}
}</script>
</head><body>
<BODY onkeydown = "keypress()";>
</body>
</html>

lol, whoops!! you have 2 <body>'s
i dont really understand the problem that you're having. if you REALLY want to use XML, i cant help you with that, but if it doesnt matter what you use, restate your question so that it's easy to understand cuz i think what you're saying is that you want to use the form to input something into some file or database and then go back to the original page. cuz that'd be easy, im just confused about it. good luck though
FBI Agent
AIM: EliteAssassin187

Yea you're right- two body's. I removed one but it still doesnt work. I'm trying to use XMLHTTREQUEST so that the form is submitted but nothing is returned- ie. you click the button, it triggers a file on the server (via PHP- though I could change that...) and thats that- nothing has to be returned to the browser...
AnonProxy's example is what I believe that I'm looking for, but I seem to have implemented it incorrectly...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |