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 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机