gpt4 book ai didi

php - session 变量未从 php 的下拉菜单中存储

转载 作者:行者123 更新时间:2023-11-30 01:17:07 24 4
gpt4 key购买 nike

我已经查找了许多不同的存储 session 变量的方法,但似乎无法找到为什么我的 session 变量没有从下拉菜单中存储。这是我的 Campaign_select.php 代码,然后在按下提交按钮后转到 store_select.php。

    <?php
session_start ();
$host="localhost"; // Host name
$username="sxx2"; // Mysql username
$password="xxxxx!"; // Mysql password
$db_name="sxxxxx"; // Database name
$tbl_name="campaign"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$query = "SELECT campaignname FROM campaign";
$result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_assoc($result))
{
$dd .= "<option value='{$row['campaignID']}'>{$row['campaignname']}</option>";
}
if ($_POST['Submit'])
{

if(isset($_POST['campaignname']))
{
$_SESSION['campaign']=$_POST['campaignName'];
}
}
$_SESSION['test']="bye";
?>

<form action="store_select.php" method="post">
<select name="campaignName" id="campaignname"><? echo $dd; ?></select>
<input name="Submit" type="submit" value="Submit">
</form>

这是 store_select.php:

<?php
session_start();
$host="localhost"; // Host name
$username="sxxxx2"; // Mysql username
$password="Wxxxx1!"; // Mysql password
$db_name="xxxx2"; // Database name
$tbl_name="users"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$campaign=$_SESSION['campaign'];
echo $_SESSION['campaign'];
echo $_SESSION['test'];

$query = "SELECT storename FROM stores WHERE campaignname='$campaign'";
$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_assoc($result))
{
$dd .= "<option value='{$row['storeID']}'>{$row['storename']}</option>";
}
?>
<form action="" method="post">
<select name="stores"><? echo $dd; ?></select>
</form>

最佳答案

替换

<form action="store_select.php" method="post">

<form action="" method="post">

if(isset($_POST['campaignname']))

if(isset($_POST['campaignName']))

关于php - session 变量未从 php 的下拉菜单中存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18945818/

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