我的php代码中的会话_start()不工作
我不知道为什么刷新index.php后会话_start()不起作用 index.php页面应打印“echo$\u SESSION['reg\u code'];//刷新此页面前用户输入的密钥传递” 。。。但是不要展示这个我的php代码中的会话_start()不工作,php,Php,我不知道为什么刷新index.php后会话_start()不起作用 index.php页面应打印“echo$\u SESSION['reg\u code'];//刷新此页面前用户输入的密钥传递” 。。。但是不要展示这个 ///////////////////////index.php////////////////////////// <?php session_start(); if(isset($_POST['reg_code'])){ if (!emp
///////////////////////index.php//////////////////////////
<?php
session_start();
if(isset($_POST['reg_code'])){
if (!empty($_POST['reg_code'])) {
$_SESSION ['reg_code'] =htmlspecialchars($_POST['reg_code']);
}
}
echo $_SESSION ['reg_code'];
?>
<form action="index.php" method="POST" enctype="multipart/form-data">
<center>
please enter your key pass :
<br>
<br>
<input placeholder="type here..." type="text" style="width: 400px; border-right: 8px; text-align: center;" name="reg_code"><br><br>
<input type="submit" name="submit" value="submit">
</center>
</form>
//index.php//////////////////////////
请输入您的密码:
我认为您正在获得$\u会话['reg\u code']==null。如果会话不包含任何值,则它将无法工作。只需尝试获取数据$\u POST['reg\u code']是否为空
测试。好极了
<?php
session_start();
if(isset($_POST['reg_code']) && !empty($_POST['reg_code'])){
$_SESSION ['reg_code'] =htmlspecialchars($_POST['reg_code']);
echo $_SESSION ['reg_code'];
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<center>
please enter your key pass :
<br>
<br>
<input placeholder="type here..." type="text" name="reg_code"><br><br>
<input type="submit" name="submit" value="submit">
</center>
</form>
请输入您的密码:
我认为您正在获得$\u会话['reg\u code']==null。如果会话不包含任何值,则它将无法工作。只需尝试获取数据$\u POST['reg\u code']是否为空
测试。好极了
<?php
session_start();
if(isset($_POST['reg_code']) && !empty($_POST['reg_code'])){
$_SESSION ['reg_code'] =htmlspecialchars($_POST['reg_code']);
echo $_SESSION ['reg_code'];
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<center>
please enter your key pass :
<br>
<br>
<input placeholder="type here..." type="text" name="reg_code"><br><br>
<input type="submit" name="submit" value="submit">
</center>
</form>
请输入您的密码:
请像这样尝试
<?php
session_start();
if(isset($_POST['reg_code']) && !empty($_POST['reg_code'])){
$_SESSION ['reg_code'] =htmlspecialchars($_POST['reg_code']);
}
if(isset($_SESSION ['reg_code']) && !empty($_SESSION ['reg_code'])){
echo $_SESSION ['reg_code'];
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<center>
please enter your key pass :
<br>
<br>
<input placeholder="type here..." type="text" style="width: 400px; border-right: 8px; text-align: center;" name="reg_code"><br><br>
<input type="submit" name="submit" value="submit">
</center>
</form>
请输入您的密码:
我希望这对你有帮助。
谢谢。请像这样试试
<?php
session_start();
if(isset($_POST['reg_code']) && !empty($_POST['reg_code'])){
$_SESSION ['reg_code'] =htmlspecialchars($_POST['reg_code']);
}
if(isset($_SESSION ['reg_code']) && !empty($_SESSION ['reg_code'])){
echo $_SESSION ['reg_code'];
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<center>
please enter your key pass :
<br>
<br>
<input placeholder="type here..." type="text" style="width: 400px; border-right: 8px; text-align: center;" name="reg_code"><br><br>
<input type="submit" name="submit" value="submit">
</center>
</form>
请输入您的密码:
我希望这对你有帮助。
谢谢。$\u POST['reg\u code']不是空的。。。此变量由用户设置。请勿使用此。。。刷新页面后,会话数据也没有显示…$\u POST['reg\u code']不是空的。。。此变量由用户设置。请勿使用此。。。刷新页面后,会话数据也没有显示…感谢您的回答,此代码有效。但是当我们刷新页面时,它不会在页面上打印任何内容。如果需要打印会话中存储的用户输入的“密钥传递”值,请继续打印。milad,我也测试过了。刷新页面后,还会显示会话数据。您的html代码和PHP代码在同一个文件中吗?谢谢您的回答,这段代码很有效。但是当我们刷新页面时,它不会在页面上打印任何内容。如果需要打印会话中存储的用户输入的“密钥传递”值,请继续打印。milad,我也测试过了。刷新页面后,还会显示会话数据。您的html代码和PHP代码在同一个文件中吗?