'How to auto login to another website using php?

How to auto login to another website using php? I try to run Code PHP webA but it shows login page but not auto login

Am I correct how I write?

Code PHP webA

<?php
$myuser="123";
$mypass="abc";
$webpage=file_get_contents("http://webB.com/login.php");
$webpage=str_replace('<input type="password" name="password">','<input type="password" name="password" value="'.$mypass.'">',$webpage);
$webpage=str_replace('<input type="text" name="username">','<input type="username" name="text" value="'.$myuser.'">',$webpage);
echo $webpage;
?>

Code WebB login.php

<?php
session_start();
?>
<?php
require_once 'includes.php';

session_start();

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $login = (new Login())->login();
    die;
}
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
    document.addEventListener('contextmenu', event => event.preventDefault());
  </script>
    <title>Login</title>
    <link rel="stylesheet" href="normalize.css">
    <link rel="stylesheet" href="style.css">
</head>
<body>
<center>
<h1>TITTLE</h1>
<section class="loginform cf">
    <form name="login" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" accept-charset="utf-8">
        <ul>
                <label for="username">Username</label>
                <input type="username" name="username" placeholder="username" required><br><br>
                <label for="password">Password</label>
                <input type="password" name="password" placeholder="password" required><br><br>
                <input type="submit" value="Login">
        </ul>
    </form>
</section>
</center>
</body>
</html>

How to auto login to another website using php? I try to run Code PHP webA but it shows login page but not auto login Am I correct how I write?

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source