I have 2 pages:
Codes:
http://emailser1.hostzi.com/default.php cointains:
<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 cointains:
<?php
echo $_POST["address"];
echo "<br />";
echo $_POST["age"];
?>
Now how can i submit the form index.html and get the value from sentmail.php and echo in mirc? I just need a example >.<
It's important to know how HTTP requests (or POST requests, in this case) work. /default.php
is used by users for providing the data to /dira/sentmail.php
. However, POST requests sent by an application have no need for the HTML that makes up the form. Instead, they just send the raw data to the receiving file, in this case /dira/sentmail.php
.
I've made the following example that should show you how POST requests work in mIRC (or any other language, for that matter). This can be triggered with /postForm <address> <age>
, which then echoes all of the data into the status window.
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
}
I hope this helps you. If you need some explanation of the code, feel free to ask questions.