我有一个简单的示例形式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>
还有一个php脚本,它通过简单地打印在前一页print.php
的两个输入中输入的值来处理POST操作
<?php
echo("First name: " . $_POST['firstname'] . "<br />'n");
echo("Last name: " . $_POST['lastname'] . "<br />'n");
?>
如果可能的话,当将数据发布到表单时,我如何使用cURL通过向服务器提交参数来获得正确的HTML响应
当我运行命令时:
$ curl -d "firstname=Ray&lastname;=Charles" http://mysiteurl.com/myForm.php
我只从myForm.php 中获得HTML
提交目标应该是print.php
,而不是myForm.php
。
$ curl -d "firstname=Ray&lastname=Charles" http://mysiteurl.com/print.php