gpt4 book ai didi

php - 如何在PHP的同一页面上获取文本框的值

转载 作者:行者123 更新时间:2023-12-02 07:35:06 24 4
gpt4 key购买 nike

这是我的代码:

<form action="" method="get" >
<input type="text" name="un">
<input type="password" name="un2" />
<input type="submit" value="submit" name="submit" />
</form>

<?php
$users1 = $_GET["un"];
$id = $_GET["un2"];
echo $users1;
?>

我无法通过这种方式显示

错误:
Notice: Undefined index: un in C:\wamp\www\vas1\register1.php on line 31

第31行:
$users1 = $_GET["un"];

最佳答案

这只是一个通知。您需要检查是否正在提交表单:

if(!empty($_POST)) {
$users1 = $_POST['un'];
echo $users1;
}

您不能使用 get,因为您的表单使用的是 post:
<form action="" method="post">

关于php - 如何在PHP的同一页面上获取文本框的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17391149/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com