我知道我的curl脚本工作正常。我可以硬编码的电子邮件,并在curl传递,它的工作很好,但现在我试图创建一个php脚本输入它,它不工作。我将在下面发布链接和代码。我正在使用输入email@ccc.com:pass .
http://cyber-hosted.com/CH/index.html
<html>
<head>
</head>
<body>
<form action="n.php" method="post">
<input type="text" name="mail />
<input type="password" name="pass" />
</form>
</body>
http://cyber-hosted.com/CH/n.php
<?php
$usermail = $_POST['Mail'];
$pass = $_POST['pass'];
$url = "https://secure.tesco.com/register/default.aspx?vstore=0";
//
$h = curl_init();
curl_setopt($h, CURLOPT_URL, $url);
curl_setopt($h, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($h, CURLOPT_POST, true);
curl_setopt($h, CURLOPT_POSTFIELDS, "form=fSignin&from=https%3A%2F%2Fsecure.tesco.com%2Fclubcard%2Fmyaccount%2Fhome.aspx&formData=bmV3UmVnPWZhbHNlJg%3D%3D&loginID=$usermail&password=$pass&seamlesswebtag=&confirm-signin.x=47&confirm-signin.y=18");
curl_setopt($h, CURLOPT_HEADER, true);
curl_setopt($h, CURLOPT_RETURNTRANSFER, true);
curl_setopt($h, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($h, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($h, CURLOPT_FOLLOWLOCATION, true);
//
$result = curl_exec($h);
echo $result;
?>
您输入的邮件大写:
$usermail = $_POST['Mail'];
// here -----^
改为:
$usermail = $_POST['mail'];
啊,我差点忘了这里的双引号:
<input type="text" name="mail />
<!-- here --------^ --->
应该是<input type="text" name="mail" />
尝试给字段一个value属性
<input type="text" name="mail" value=""/>
<input type="password" name="pass" value=""/>
你还缺少提交按钮从你提供的代码
<input type="submit" name="submit" value="Submit"/>
最后你应该在cURL请求中URL编码usermail和password参数