douzhenyu6533 2018-06-07 09:37
浏览 54
已采纳

如何将会话变量传递到PHP中的表单?

I currently have this code but it is not display the u_mail

if (isset($_SESSION['u_email'])) {
echo "<form method='POST' action='".setComments($connComment)."'>
<input type='hidden' name='uid' value='$_SESSION['u_email']'>
</form>" } 
getComments($conn)

How do I display it?

I tried testing it by doing:

<?php
 echo $_SESSION['u_email'];
 ?>

And it works completely fine. It is just when I put it in an echo. I actually SHOULD put it in echo. Is there a way in PHP to do that?

Thank you!

  • 写回答

1条回答 默认 最新

  • dongmei8460 2018-06-07 09:40
    关注

    Just break out from the string and concatenate, like this:

    echo "<form method='POST' action='".setComments($connComment)."'>
    <input type='hidden' name='uid' value='" . $_SESSION['u_email'] ."'>
    </form>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vue使用gojs3.0版本,在nodeDataArray中的iconSrc使用gif本地路径,展示出来后动画是静态的,不是动态的
  • ¥100 代写个MATLAB代码,有偿
  • ¥15 ansys electronics 2021 R1安装报错,错误代码2,如图
  • ¥15 Dev-c++打字不出现中文,但出现日文
  • ¥30 搭建面包板由NE555N和SN74LS90N组成的计时电路时出了问题
  • ¥15 无源定位系统的时差估计误差标准差
  • ¥15 请问这个代码哪里有问题啊
  • ¥20 python--version在命令端输入结果Python is not defined怎么办?还有pip不是exe格式是不是没安装成功?
  • ¥15 通过GaussianView进行结构微调消除虚频
  • ¥15 调用transformers库