[数组值插入php

问题描述 投票:0回答:1

我希望我提供用户名和密码并提交它。用户名将保存到一个数组中,并且我将使用该数组打印所有用户名。

<?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>

php html
1个回答
0
投票

您要做的是在服务器端存储数据。

PHP by itself is stateless,这意味着它不维护请求之间的信息。您需要将其与其他东西一起使用来存储用户名和密码列表。

有不同的方法可以执行此操作,具体取决于您要执行的操作。也许您想将此信息存储在session variables中,或者您想将此信息存储在in a database中。

© www.soinside.com 2019 - 2024. All rights reserved.