0

我有 2 页:

代码:
http ://emailser1.hostzi.com/default.php 包含:

<html>
<head><title></title></head>
<body>
<form action="formsend.php" method="post">

    address: <input type="text" name="address">
    <br/>
    age: <input type="text" name="age">

    <input type="submit" value="send">
</form>
</body>
</html>

http://emailser1.hostzi.com/dira/sentmail.php包含:

<?php
echo $_POST["address"];
echo "<br />";
echo $_POST["age"];
?>

现在我如何提交表单 index.html 并从 sendmail.php 中获取值并在 mirc 中回显?我只需要一个例子>.<

4

1 回答 1

1

了解 HTTP 请求(或 POST 请求,在这种情况下)如何工作非常重要。/default.php用户使用它来向/dira/sentmail.php. 但是,应用程序发送的 POST 请求不需要构成表单的 HTML。相反,他们只是将原始数据发送到接收文件,在这种情况下是/dira/sentmail.php.

我制作了以下示例,该示例应该向您展示 POST 请求如何在 mIRC(或任何其他语言)中工作。这可以用 触发/postForm <address> <age>,然后将所有数据回显到状态窗口中。

alias postForm {
  var %address = $$1
  var %age = $$2
  var %sockname = postForm. $+ $ctime

  sockopen %sockname emailser1.hostzi.com 80
  sockmark %sockname %address $+ , $+ %age
}
on *:SOCKOPEN:postForm.*:{
  var %data = address= $+ $gettok($sock($sockname).mark, 1, 44) $+ &age= $+ $gettok($sock($sockname).mark, 2, 44)

  sockwrite -nt $sockname POST /dira/sentmail.php HTTP/1.1
  sockwrite -nt $sockname Host: emailser1.hostzi.com
  sockwrite -nt $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -nt $sockname Content-Length: $len(%data)
  sockwrite -nt $sockname $crlf $+ %data
}
on *:SOCKREAD:postForm.*:{
  var %sockread
  sockread %sockread
  echo -st %sockread
}

我希望这可以帮助你。如果您需要对代码进行一些解释,请随时提出问题。

于 2013-04-09T10:15:11.070 回答