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

如何访问受密码保护的php脚本以及如何使用post方法向其发送数据?,php,Php,我想访问受密码保护的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_R

我想访问受密码保护的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>

当我把用户名和密码放在链接的开头时,这段代码不起作用,如果我没有把用户名和密码放在链接的开头,那么这段代码就正常工作了,但是询问password Manual时,你应该使用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);

这不是完整的代码。

在Oauth机制的帮助下使用CURL。很抱歉,你能用示例解释我编程PLZ吗感谢你的帮助Bjorn,但我没有正确地得到你的答案,我想在html代码中添加代码,这样当我们通过submit按钮调用action方法时,我就不知道如何在html中基本上使用你需要的代码要做的是:1。将HTML表单发布到PHP页面。2.让PHP文件验证表单数据,然后执行curl脚本部分。3.将HTML页面返回给用户,确认表单已提交。我快速浏览了您的网站sevaram.com/sevaraam_RFID/Scripts/login.php。不返回任何特殊的身份验证请求?我希望在访问h login.php页面时得到401身份验证响应?