Hi all,

I've got a wireless print server, DLink DP-G321, that seems to need a 'reset' fairly often. This is normally done manually by going to the print servers web interface management pages and clicking on a button that is a javascript button. Here's the code from that page:

<FORM ACTION=/ReplyT.htm METHOD=POST>
....blah
<a href=javascript:document.forms[0].submit()>
....blah
</form>

I would like to be able to write a PHP script that I could schedule in the windows xp scheduler, that would essentially 'click' that button for me and do the reboot at that scheduled time.
I'm running PHP 5.0.4 on apache 2.0.54 on winxp pro.
Any suggestions/links to tutorials on how to do this sort of thing (php script to 'submit' a form) would be greatly appreciated.

Thanks.

    U need a curl script that send through POST all the element of the form to the form action ...

      One of the most straightforward methods would be to capture the HTTP request this form would make - its headers and so forth - and store that in a string. Then PHP can use fsockopen() to connect to the host, and fwrite() the contents of that string to the socket. Bang: one POSTed form. Other solutions could involve installing cURL, but that's overboard for such a small task. Another would be to bone up on http and how POST requests are formatted, and store a hand-coded request in the string, but personally I'd take the first option (mainly since I have the LiveHTTPHeaders extension installed on Firefox and I can just copy-and-paste the request from that and cut out the redundant headers).

        17 days later

        Thanks for the replys!

        Weedpacket, your right. curl is over kill in this case. Using fsockopoen and fputs, I've accomplished what I needed, and with only 4 lines of simple code (if the logging and error checking is not counted). Very clean. Thanks for the suggestion! 😃

          Write a Reply...