1

I want that whenever i give username and password and submit it.The username will save into an array.and i will print all username using that array.

<?php


if(isset($_POST['submit'])){
    echo "Welcome!"."<br>";

 $username=$_POST['username'];
 $password=$_POST['password'];

    echo "Username = ".$username."<br>";
    echo "Password = ".$password."<br>";

    }
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form action="index.php" method="post">
        <input type="text" name="username" placeholder="Username">
        <input type="password" name="password" placeholder="Password">
        <input type="submit" name="submit">
    </form>
</body>
</html>

Nayeem Ahmed
  • 91
  • 1
  • 5

1 Answers1

0

What you want to do is store your data server-side.

PHP by itself is stateless, which means it doesn't maintain information between requests. You need to use it along with something else to store your list of usernames and passwords.

There are different ways to do this, depending on what you're aiming to do. Maybe you want to store this information in session variables, or maybe you want to store this information in a database.

Joundill
  • 6,828
  • 12
  • 36
  • 50