dsa5211314 2014-10-04 18:24
浏览 31

无需javascript即可顺利登录

What i want: clicking on login / pressing on enter will validate the login and redirect if correct (without javascript).

What i tried:

  1. A form with a submit button and validating on an other php page PROBLEM: if login is not correct, i don't want to redirect and display an error message instead.
<form action="loginServerside.php" method='POST'>
  1. A form with a submit button and validating when the submit button is set. PROBLEM: submit button reloads page and then redirects if login was correct
<form method='POST'>
      <input name="email" type="email" id="email" placeholder="Email" />
      <input name="pass" type="password" id="pass" placeholder="Password">
      <input type="submit" name='login' value="LOGIN" id="login" class="button"/>
</form>
if (isset($_POST['login']))
     /*validate*/
  1. Trying to prevent the page reload by using an input type="button" PROBLEM: the isset only works for submit buttons

I would appreciate the help!

  • 写回答

4条回答 默认 最新

  • donglan9517 2014-10-04 18:31
    关注

    You can't run server-side code (login credentials validation, in this case) without reloading the page. This requires AJAX, which involves Javascript.

    评论

报告相同问题?

悬赏问题

  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题