为什么我的模态不起作用?使用POST方法是错误的吗?当我加载页面并单击忘记密码的链接时,最终显示模态,然后当我输入我的电子邮件时没有任何反应。有人能帮助我吗?
这是我的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代码
<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>
答案 0 :(得分:2)
首先,您没有提交&#34;提交&#34;与$_POST['submit']
一起使用的name属性以及它失败的原因,因此if(isset($_POST['submit'])){...}
中的任何内容都不会被执行。
这样做:
<button type="submit" class="getPasswordButton" name="submit">Send</button>
或输入:
<input type="submit" class="getPasswordButton" name="submit" value="Send">
另外,MYSQL_ASSOC
需要MYSQLI_ASSOC
。你不能混合使用MySQL函数。
但是,查看可能需要使用if(mysqli_num_rows($sql2) < 1){
运算符更改的>
。做< 1
告诉MySQL它是否不存在; 洞察。
答案 1 :(得分:1)
您的表单必须具有<form action="your/php/script.php" method="post">
属性。其值必须是处理表单的脚本文件的名称。
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
或者,如果php脚本与表单在同一页面上,您可以写:
namespace oP
{
enum adjustment
{
AUTO_OFF,
AUTO_ONCE,
AUTO_CONTINUOUS,
AUTO_SEMI,
ABSOLUTE, // The line that the errors point to.
NUDGE
};
}