Hi,
Read up on PHP socket programming for starters:
http://www.php.net/sockets
Basic idea:
1) PHP connects to router via socket_create()
2) PHP sends username/password via socket_send() and gets the response via socket_read().
3) If we're connected ok, PHP sends the first command via socket_send()
4) PHP reads the router's response via socket_read()
5) If the response looks ok (ie. the router understood the command), we repeat steps 3 and 4 for each new command.
5) When we're done, PHP closes the connection via socket_close()
I'm sure between the scripts you have and the documentation on PHP's website, you'll have no problem accomplishing what you need.
Chris