如何使一个脚本(PHP)登录到一个网站(没有API),并单击一个按钮


how to make a script (PHP) that login to a site (No API) and clicks a button?

我想创建一个脚本,登录到一个网站,点击一个按钮,就是这样。

我只需要在谷歌上搜索词汇(关键词),因为我真的迷路了。

如果你是好人,做一个例子!谢谢你!

基本HTTP认证,HTTP认证与PHP, PHP要求和包括,安全登录脚本PHP,用户认证PHP, PHP简单登录脚本,登录认证与sql和PHP。

以下是一些有用的网站:

http://www.developerdrive.com/2013/05/adding-a-simple-authentication-using-php-require-and-includes/

http://php.net/manual/en/features.http-auth.php

http://blackbe.lt/php-secure-sessions/

http://docstore.mik.ua/orelly/webprog/pcook/ch08_10.htm

首先创建一个与数据库类似的连接字符串邮件= cleanstr美元($ _POST['邮件']);$ pwd = cleanstr ($ _POST['密码']);使用这两个变量来登录系统邮箱id和密码

<?php
require_once("connection.php"); // require the db connection
function cleanstr($str){
    $cstr=trim($str);
    $cstr=htmlspecialchars($cstr);
    $cstr=addslashes($cstr);
    return $cstr;
}
$email=cleanstr($_POST['email']);
$pwd=cleanstr($_POST['password']);
if(empty($email) && empty($pwd)){
        header("location:index.php");
    }
   else
{
$email=cleanstr($_POST['email']);
$pwd=cleanstr($_POST['password']);
  $search = mysql_query("SELECT * FROM users WHERE email='".$email."' AND password='".$pwd."'") or die(mysql_error());
    $match  = mysql_num_rows($search);
    if($match>0)
    {
 session_start();
 $_SESSION['email']= $email;
 // log in declare to the other page
 $_SESSION['login']=True;

header("Location:index.php");
    }
    else
    {
     echo "<script>
        window.alert ('Email or Password not match');
        window.location.href='login.php';
        </script>"; 
    }
// end of if
} 
?>