我尝试使用另一个站点的现有帐户登录。[帐户是在 zwinky 上制作的。]
PHP 代码如下所示:
<?php
$Luser = "swagg_ma_blue";
$Lpass = "mypassword";
$L_info = "http://registration.zwinky.com/registration/loginAjax.jhtml?
username=".$Luser."&password=".$Lpass;
$zwinky_login_file = file_get_contents($L_info, true);
if (substr($zwinky_login_file, 12, 1) == "u"){ $message = "Blank username!"; }
if (substr($zwinky_login_file, 12, 1) == "p"){ $message = "Blank password!"; }
if (substr($zwinky_login_file, 12, 1) == "w"){ $message = "Wrong user/pass combination!"; }
if (substr($zwinky_login_file, 12, 1) == "s"){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL , $L_info);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "sessions/".$Luser);
curl_setopt($ch, CURLOPT_COOKIEJAR, "sessions/".$Luser);
$response = curl_exec($ch);
curl_close($ch);
$_SESSION['username'] = $Luser;
$_SESSION['password'] = $Lpass;
header('Location: ../index.html');
die;
}
?>
Html 代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Sign In</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<!-- Warning -->
<div class="alert alert-info">
Please sign in with your Zwinky account!
</div>
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" id="Luser" class="input-block-level" placeholder="ZwinkyUsername">
<input type="password" id="Lpass" class="input-block-level" placeholder="ZwinkyPassword">
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
</div>
</div>
</body>
</html>
但我不知道,如果我使用不存在的帐户,它不会显示任何错误消息。我还想将输入的信息保存到文本文档中。有人知道一些信息吗?还是提示?
非常感谢