忘记密码PHP/AJAX

忘记密码PHP/AJAX,php,html,ajax,ajaxform,Php,Html,Ajax,Ajaxform,晚上好,我有一个表格要求忘记密码,代码似乎要工作,但它没有发送任何东西,我不明白为什么?另一方面,我有我的信息,没有与此地址对应的帐户:(谢谢你的帮助 html代码: <div id="valider" class="col-md-6 col-md-offset-2 col-sm-12 col-xs-12"> <div class="alert alert-info" role="alert" id="alert"><i class="fa fa-circl

晚上好,我有一个表格要求忘记密码,代码似乎要工作,但它没有发送任何东西,我不明白为什么?另一方面,我有我的信息,没有与此地址对应的帐户:(谢谢你的帮助

html代码:

<div id="valider" class="col-md-6 col-md-offset-2 col-sm-12 col-xs-12">
    <div class="alert alert-info" role="alert" id="alert"><i class="fa fa-circle" aria-hidden="true" style="margin-right:2px;font-size:8px;color:#30b305;"></i>
        Pour réinitialiser votre mot de passe, inscrivez votre adresse mail ci-dessous.
    </div>
    <div class="alert alert-danger" style="display: none;">
        Aucun compte ne correspond à cet adresse !
    </div>
    <div class="alert alert-success" id="success" style="display: none;">
        Les instructions pour réinitialiser votre mot de passe vous ont été envoyer par e-mail !
    </div>
    <form method="post" action="" id="password">
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="form-group validate-input">
                    <label for="email"><i class="fa fa-at" id="user"></i>Votre adresse mail</label>
                    <input type="email" class="form-control input-label" id="email" name="email"   placeholder="Email" required>
                </div>
            </div>
            <div class="col-md-12 col-sm-12 col-xs-12">
                <button type="submit" class="btn-default btn abt-btn" name="envoi">Valider<i class="fas fa-sign-in-alt sign" style="margin-left: 5px;"></i>
                    <i class="fa fa-circle-o-notch fa-spin loading hide" style="margin-left: 5px;"></i>
                </button>
            </div>
        </div>
    </form>
</div>
$('#valider form').on('submit', function(e) {
    form = $(this)
    valider = $(this).closest('#valider');
    button = form.find('button');
    alert_danger = valider.find('.alert-danger');
    alert_success = valider.find('.alert-success');
    $.ajax({
        url: './users/password.php',
        type: 'POST',
        data: $('#valider').serialize(),
        dataType: 'json',
        beforeSend: function() {
            $(".sign").addClass("hide");
            button.html("Connexion...");
            button.prop('disabled', true);
            alert_danger.fadeOut(100);
        }
    }).done(function(success) {
        if(success) {
            form.hide();
            alert_success.fadeIn(function() {
                setTimeout(function(){
                    window.location.replace("http://localhost/xampp/DEv/connect_succefully.php");
                }, 4000)
            });
        } else {
            alert_danger.fadeIn();
            button.html("Se connecter");
            button.prop('disabled', false);
        }
    });
    e.preventDefault();
});
Php代码:

$success = true;
if(!empty($_POST) && !empty($_POST['email'])){

include '../inc/init.php';

$email = trim($_POST(['email']));
//on regarde si le mail existe dans la base.
$sql_selectMembre = "SELECT * FROM users WHERE email = ? AND actif = 1 AND code_activation IS NOT NULL";
$req_selectMembre = $pdo->prepare($sql_selectMembre);
$req_selectMembre->execute(
    [
        'email' => $email
    ]
);

//si le mail existe dans la base
if($req_selectMembre->rowCount() == 1)
{
    session_start();
    $code_reset = sha1(microtime());
    $sql_updateMembre = 'UPDATE users SET code_reset = ? AND reset_at = NOW() WHERE id = ?';
    $req_updateMembre = $pdo->prepare($sql_updateMembre);
    $req_updateMembre->execute(
        [
            'email' => $email,
            'id' => $req_selectMembre['id']
        ]
    );

    $lien_validation = CONFIG['website'].'../reset_password.php?email='.$email.'&code_reset='.$code_reset;

    send_mail(
        $email,
        "Réinitialisation de votre mot de passe",
        content_mail_password_html($lien_validation),
        content_mail_password_text($lien_validation)
    );
    $success = true;
}
}
die(json_encode($success));

您需要这个
数据:$('#valider form')。serialize(),

这是一个怎样的“php”问题?你的php代码在哪里?php代码被加载了,他不想被加载。你可以模拟你的请求测试你的php代码并查看结果吗?顺便说一句……如果你开始编写代码,我建议你用英语编写代码,包括变量、注释和函数名。你的问题是,我有一个表单,用于请求忘记密码code似乎想工作,但它不发送任何东西,我不明白为什么?如果你将数据:$('#valider')。serialize()替换为数据:$('#valider form')。serialize(),数据将被发送,我测试了它。是的,谢谢,现在我认为问题来自php代码,但我无法解决它