0

我知道我的 curl 脚本可以正常工作。我可以硬编码电子邮件并传入 curl 并且它工作正常,但现在我正在尝试创建一个 php 脚本来输入它并且它不起作用。我将在下面发布链接和代码。我正在使用输入 email@ccc.com:passss。

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;
?>
4

2 回答 2

1

You typed mail with uppercase:

$usermail = $_POST['Mail'];
//        here -----^

Change it to:

$usermail = $_POST['mail'];

Ah and I almost forgot the double quotes here:

<input type="text" name="mail />
<!--            here --------^    --->

It should be <input type="text" name="mail" />

于 2013-04-25T22:34:32.393 回答
0

尝试给字段一个值属性

<input type="text" name="mail" value=""/>
<input type="password" name="pass" value=""/>

此外,您提供的代码中缺少提交按钮

<input type="submit" name="submit" value="Submit"/>

最后,您应该对 cURL 请求中的用户邮件和密码参数进行 URL 编码。

于 2013-04-25T22:53:22.337 回答