会话名称未显示 [英] Session name not showing
本文介绍了会话名称未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对此有帮助
Welcome.html:
<?php
include(session.php);
?>
< html>
< h1>欢迎<?php echo $ login_session; ?>< / H1>
< / html>
Session.php
:
<?php
include(db_connection.php);在session_start();
$ user_check = $ _SESSION ['login_user'];
$ ses_sql = mysqli_query($ conn,从用户选择First_name,其中Email ='$ user_check');
$ row = mysqli_fetch_array($ ses_sql,MYSQLI_ASSOC);
$ login_session = $ row ['First_name']; ?>
解决方案
welcome.html?尝试以.php格式执行它,或者您不能在html文件中执行php,除非您指示Apache将.html文件视为PHP
来执行此操作,
在你的网站的根目录下创建一个.htaccess文件并添加以下行:
[Apache2 @ Ubuntu / Debian:use this指令]
AddType应用程序/ x-httpd-php .html .htm
如果你正在将PHP作为CGI运行(可能不是这种情况),你应该编写代码:
AddHandler application / x-httpd -php .html .htm
请尝试localhost / server!
Am trying to show the value of the $login_session in my welcome page but it doesn't show. Any help on that
Welcome.html:
<?php
include("session.php");
?>
<html>
<h1>Welcome <?php echo $login_session; ?></h1>
</html>
Session.php
:
<?php
include ("db_connection.php"); session_start();
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($conn,"select First_name from User where Email = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_session = $row['First_name']; ?>
解决方案
welcome.html ? try executing it as .php or You can't execute php in html file, unless you instruct Apache to treat .html files as PHP
to do this , Create a .htaccess file at the root of your website and add this line:
[Apache2 @ Ubuntu/Debian: use this directive]
AddType application/x-httpd-php .html .htm
If your are running PHP as CGI (probably not the case), you should write instead:
AddHandler application/x-httpd-php .html .htm
Also try with localhost / server !
这篇关于会话名称未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文