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>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?