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>

1
  • Read this: PHP array_push Commented May 3, 2020 at 21:42

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.