duanli8391 2012-03-09 01:32
浏览 18
已采纳

如何在没有表单或Javascript的情况下触发logout.php脚本?

I want to have a button, that logs out the user on click. But I don't feel like creating a form for that, or making an "onclick" handler. Is there another way to do it?

<p class='loginposition normal'>
."$_SESSION['email']".<form action='/logout.php' method='post'><input class='logout-submit button' type='submit' style='float:right;' id='logoutbtn' value='Log Out'></form>
</p>";

I want them to be in one raw: user@user.com [Log Out]

  • 写回答

6条回答 默认 最新

  • dpc57092 2012-03-09 01:36
    关注

    If you want a POST request then you need either Ajax (which would be a silly technique to use for logging out) or a form.

    Since logging out is not a repeatable action, POST is the correct tool to do it.

    Get over your feelings and use a form.

    You can deal with the twin problems of your HTML being invalid and additional line breaks by putting the paragraph inside the form instead of the other way around.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)
编辑
预览

报告相同问题?