HTTP request for reference

I made a simple web page in php to check the message request from telnet. Here is the webpage code (example.php):

<html>
<body>
<form method="post" action="example.php>">
Your Name:<input type="text" size="12" maxlength="12" name="Name"><br />
<input type="submit" value="submit" name="submit">
</form> 
<?php echo $_POST["Name"]; ?>
</body>
</html>

This works from a browser, but I would like to test it from telnet. I tried:

telnet localhost 80
POST example.php HTTP/1.0
Host: localhost
Content-Type: text/html; charset=iso-8859-1
Content-Length: 11

Name=myname

But that will not work ... any help?

+3
source share
2 answers

change your content type

POST /example.php HTTP/1.0
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 11

Name=myname
+2
source

Konerak is right. Take a look at the real request. For example, Content-Type. I just tried and got

Content-Type: application/x-www-form-urlencoded

You also lack a second form field: your button. But I think it doesn’t matter ...

Name=myname&submit=submit

take a look at http://en.wikipedia.org/wiki/POST_%28HTTP%29 for more details and a good starting point for your research ...

Update : try

POST /example.php HTTP/1.0
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: 11

Name=myname

at least it worked for me ...

+4
source

All Articles