简体   繁体   English

数组值插入 php

[英]array value insert in php

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>

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. PHP 本身是无状态的,这意味着它不维护请求之间的信息。 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 .也许您想将此信息存储在session 变量中,或者您可能希望将此信息存储在数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM