第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP會話未顯示值

PHP會話未顯示值

PHP
大話西游666 2022-10-22 15:57:18
<?php    session_start();?><html>    <head>        <link href="style.css" rel="stylesheet" type="text/css">    </head>    <body>        <div class="pageContainer">            <form action="second.php" class="formLayout" method="post">                <div class="formGroup">                    <label>Name:</label>                    <input type="text" name="first_name"><br>                    <input type="hidden" name="postback" value="true"><br>                </div>                <div class="formGroup">                    <label> Car model:</label>                    <div class="formElements">                        <input type="radio" name="model" value="Mustang">Ford Mustang<br>                        <input type="radio" name="model" value="Subaru">Subaru WRX STI<br>                        <input type="radio" name="model" value="Corvette">Corvette<br>                    </div>                    <input type="submit" name="submit">            </form>            <?php                if (isset($_POST['submit'])) {                    $_SESSION["first_name"] = $_POST["first_name"];                    $_SESSION["model"] = $_POST["model"];                }            ?>        </div>    </body></html>我設(shè)置我的代碼以將“first_name”和“model”名稱的值設(shè)置到我的會話變量中。當(dāng)我嘗試訪問表單提交頁面中存儲變量的值時:<?php    session_start();?><html>    <body>        <?php            echo $_SESSION["first_name"];            echo $_SESSION["model"];        ?>    </body></html>我只收到模型值之外的值,而不是 first_name 值。我不明白我在這里做錯了什么。
查看完整描述

1 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個贊

假設(shè)您的第一個文件名為first.php. 如您所示<form>,第二個是second.php.

似乎您正在將數(shù)據(jù)寫入first.php文件中的會話,但是此代碼將永遠(yuǎn)不會運(yùn)行,因?yàn)槟鷮⒈韱翁峤唤osecond.php而不是first.php!

因此,請移動寫入會話變量的代碼second.php。要測試它是否真的有效,您可以創(chuàng)建一個third.php來顯示它們。

(我不知道為什么要看到這個model集合,但我猜你之前的測試中它仍然存在。)


查看完整回答
反對 回復(fù) 2022-10-22
  • 1 回答
  • 0 關(guān)注
  • 108 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號