【发布时间】:2017-09-04 06:44:29
【问题描述】:
我有 2 页:
- send.php
- 确认.php
在 send.php 中,我有一个输入文本框,用于由最终用户输入数字(例如:12345)(此数字是数据库中的私钥)。接下来我想将输入的数字(12345)存储在会话中。在第 2 页中,我想从会话中读取该数字(12345)并用于从数据库中选择行。但出现错误:
注意:未定义的索引:第 4 行 C:\xampp\htdocssend.php 中的 nid
<?php
include "db.php";
session_start();
$nid=$_POST["nid"];
$_SESSION['user_id']=$nid;
//$_SESSION['nid']=True;
if(isset($_POST['nid'])){
header("Location: confirm2.php");
exit;
}
<form action="send.php" method="post">
<div class="top-row">
<div class="field-wrap">
<label>
your id<span class="req">*</span>
</label>
<input type="text" required autocomplete="off" name="nid" />
</div>
<button type="submit" class="button button-block"/>submit</button>
</div>
</form>
【问题讨论】:
-
send.php 代码是什么?抱歉,我看到这是发送。但是帖子呢?这是哪里来的
-
在脚本开始时使用 print_r($_POST) 并检查是否设置了“nid”
-
@Andreas 我添加了 send.php 代码的其余部分