简体   繁体   中英

Post form data using cURL to simple form

I have a simple example form myForm.php

<html>
<head>
<title>Curling and Enjoying?</title>
</head>
<body>
<form action="print.php" method="post">
   <p>First name: <input type="text" name="firstname" /></p>
   <p>Last name: <input type="text" name="lastname" /></p>
   <input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

And the a php script which handles the POST action by simply printing the values entered in the two inputs on the previous page, print.php

<?php
   echo("First name: " . $_POST['firstname'] . "<br />\n");
   echo("Last name: " . $_POST['lastname'] . "<br />\n");
?>

If possible, how can I use cURL to get a correct HTML response by submitting arguments to the server when posting data to the form

When I run the command:

$ curl -d "firstname=Ray&lastname;=Charles" http://mysiteurl.com/myForm.php

I get only the HTML from myForm.php

提交目标应该是print.php而不是myForm.php

$ curl -d "firstname=Ray&lastname=Charles" http://mysiteurl.com/print.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM