如何访问密码保护的php脚本以及如何使用post方法向其发送数据


How to access php script which is password protected and how to send the data using post method to it?

我想访问php脚本这是密码保护和如何发送数据给它使用post方法例如登录表单

<html>
<head>
<title>Login</title>
</head>
<h3>Add entry</h3>
<p> Add another Article</p>
<form action="http://abc:abc123@www.sevaraam.com/sevaraam_RFID/Scripts/login.php" method = "post">
<label for="username">Username</label> <input type="username" id="username" name="username"><br /><br />
<label for="password">Password:</label> <input type="text" id="password" name="password" ><br /><br />
<button type = "submit">submit</button>
</form>
</html>

这个代码不工作,当我把用户名和密码在链接的开始,如果我不把用户名和密码,那么它是正常工作,但要求密码手册

您应该使用cUrl。

通过使用setop设置用户/密码,您应该能够将表单发送到服务器

$data = array('username' => 'the_username', 'password' => 'some_secret');
$myForm = curl_init(); 
curl_setopt($myForm, CURLOPT_USERPWD,"abc:abc123"); 
curl_setopt($myForm, CURLOPT_URL, "http://www.sevaraam.com/sevaraam_RFID/Scripts/login.php");
curl_setopt($myForm, CURLOPT_POST, 1);
curl_setopt($myForm, CURLOPT_POSTFIELDS, $data);
curl_exec($myForm);

不完整的代码