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

如何将会话变量传递到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!

图片转代码服务由CSDN问答提供 功能建议

我目前有这段代码但是没有显示u_mail

 <  code> if(isset($ _ SESSION ['u_email'])){
echo“&lt; form method ='POST'action ='”。setComments($ connComment)。“'&gt; 
&lt; input type ='hidden  'name ='uid'value ='$ _ SESSION ['u_email']'&gt; 
&lt; / form&gt;“  } 
getComments($ conn)
   
 
 

如何显示它?

我尝试通过以下方式进行测试:

 &lt;?php 
 echo $ _SESSION ['u_email']; 
?&gt; 
   
 
 

它工作得很好。 就在我把它放在回声中的时候。 我实际上应该把它放在回声中。 PHP中有没有办法做到这一点?

谢谢!

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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>";
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题