为什么我的Modal无法通过html表单工作? [英] Why is that my Modal isn't working through html form?

查看:105
本文介绍了为什么我的Modal无法通过html表单工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的Modal不能正常工作?使用POST方法是否错误?当我加载页面并单击忘记密码的链接时,最终会显示模式,然后当我输入电子邮件时什么也没有发生.有人可以帮我吗?

Why is that my Modal is not working? Is it wrong to use POST method? When I load the page and click the link for forgot password and the modal is eventually is display then when I input my email nothing happens. Could someone help me?

这是我的PHP脚本.

<?php
require 'db.php';
$msg='';
if(isset($_POST['submit']))
{
$emailRet = mysqli_real_escape_string($connection, $_POST['emailRetrieve']);

$sql2 = mysqli_query($connection, "SELECT Email_Address, Password FROM pawnshop WHERE Email_Address='".$emailRet."'");

while ($row = mysqli_fetch_array($sql2, MYSQL_ASSOC)) {
    $emailRetrieve = $row['Email_Address'];
    $passwordRetrieve = $row['Password'];
}

  $number = mysqli_num_rows($sql2);
  echo $number;

  if(mysqli_num_rows($sql2) < 1){  
    require 'smtp/Send_Mail.php';

    $to = $emailRetrieve;
    $subject = "PBMS Password Retrieval";
    $body ='Hi, This is your account information<br><br> Username:'.$emailRetrieve.'<br> Password:'.$passwordRetrieve.'';

    Send_Mail($to,$subject,$body);
    $msg='Check your email to get your password';
    echo 'send';
  }
  else
  {
    $msg='Check your email and try again';
  }

}
?>

这是我的Modal的html代码

This is my html code for Modal

    <html>
    <head>
      <link type='text/css' href='css/modal.css' rel='stylesheet' media='screen' />
      <script type='text/javascript' src='js/jqueryModal.js'></script>
      <script type='text/javascript' src='js/jquery.simplemodal.js'></script>
      <script type='text/javascript' src='js/modal.js'></script> 
    </head>
    <body>
    <form method="post">
    <div id='basic-modal'>
              <center>
                 <a href='#' class='basic custom-font-reg'>Forgot password?</a><br>
                 <a href='Registration.php' class='custom-font-reg'>Register for an account?</a>
              </center>
              </div>

              <hr class="hr-custom2">

              <div id="basic-modal-content">
                 <div class="getPasswordWrapper">
                 <hr class="PasswordHeaderColor"></hr>
                 <p class="enterEmailPasswordText">Enter your username to get your password</p>
                 <center>
                      <input type="text" name="emailRetrieve" class="getPassword" placeholder="Your Username\Email" required/>
                      <button type="submit" class="getPasswordButton">Send</button>
                      <span><?php echo $msg; ?></span>
                 </center>
                 </div>
              </div>
    </form>
    </body>
    </html>

推荐答案

首先,您没有带有"submit" name属性的提交与$_POST['submit']一起使用,这就是失败的原因,因此没有任何帮助在那里if(isset($_POST['submit'])){...}将被执行.

Firstly, you don't have a submit with the "submit" name attribute to go with $_POST['submit'] and that's the reason why it's failing, so nothing in there if(isset($_POST['submit'])){...} will get executed.

这样做:

<button type="submit" class="getPasswordButton" name="submit">Send</button>

或输入:

<input type="submit" class="getPasswordButton" name="submit" value="Send">

此外,MYSQL_ASSOC必须为MYSQLI_ASSOC.您不能混合使用MySQL函数.

Plus, MYSQL_ASSOC needs to be MYSQLI_ASSOC. You can't mix MySQL functions.

但是,查看可能需要使用>运算符进行更改的if(mysqli_num_rows($sql2) < 1){. < 1告诉MySQL它是否不存在. 洞察力.

However, looking at if(mysqli_num_rows($sql2) < 1){ that may need to be changed using > operator. Doing < 1 tells MySQL if it does not exist; an insight.

这篇关于为什么我的Modal无法通过html表单工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆