gpt4 book ai didi

php - 传递全局变量返回空值。第一页与模态页面然后到第二页

转载 作者:行者123 更新时间:2023-11-29 12:04:32 24 4
gpt4 key购买 nike

我在模态页面的第一页上有搜索框$_POST['search']。在模式页面上,我能够显示该搜索框中的值。但是,当我单击提交按钮在第二页上发布时,搜索框变量返回空值。请帮助我。

这是我的 html 代码

<?php

session_start();

$globalpid = $_POST['search'];

$_SESSION['search'] = "$globalpid";

?>

<?php

require_once 'config.php';
?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="Hello World">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/custom.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
</head>
<body>

<div class="contaner">

<header>

<?php require_once 'header.php'; ?>

</header>

<?php require_once 'menu.php'; ?>
<div class="container">
<div class="panel panel-default panel-info">
<div class="panel-heading"><h3 class="panel-title">Billing Section</h3></div>
<div class="panel-body">
<form action="table.php" method="POST" class="form-inline">
<div class="form-group">
<input type="text" name="search" size="50" id="element-1" class="form-control" style="margin-top: 5px;" placeholder="Enter Patient ID" /><br />
<input type="submit" name="submit" value="Search" style=" margin-top: 5px; width: 150px;" class="btn btn-info" />
</div>
</form>
</div>

<?php

if (empty($_POST['search']))
{
?>
<div class="panel-footer">
<?php echo "There was no search results!"; } ?>
</div>
</div>
</div>

最佳答案

确保您的表单操作=“第一页的网址”。我认为您没有将 $_POST['search'] 分配给 $globalpid。在第一页中尝试此代码:

首页

 <?php
session_start();
if(isset($_POST['search'])){
$globalpid = $_POST['search'];
$_SESSION['search'] = "$globalpid";
}
?>

第二页

<?php
session_start();
//print_r($_SESSION);
if(isset($_SESSION['search'])){
$globalpid = $_SESSION['search'];
echo $globalpid;
}

?>

关于php - 传递全局变量返回空值。第一页与模态页面然后到第二页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31769145/

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