繁体   English   中英

PHP If语句在输入标签值中,并且表单未处理

[英]PHP If statement in input tag value, and form not processing

我的表格未处理。 输入详细信息或什至没有输入详细信息后,我将在第95行获得else语句echo“您的密码重置密钥无效”。该密钥是正确的,但是...

我认为对于输入标签的值,第160-164行的if语句存在问题。 我认为它需要包装在php标记中,但不知道怎么了...?

希望有人能帮忙。 谢谢。

<?php

$objForm = new Form();
$objValid = new Validation($objForm);
$objUser = new User();


// Was the form submitted?
if (isset($_POST["ResetPasswordForm"]))
{

        // Form Fields Check
        if ($objForm->isPost('email')) {

            $objValid->_expected = array(
            'email',
            'password',
            'confirm_password'

            );

            $objValid->_required = array(
                'email',
                'password',
                'confirm_password'

                );


            $objValid->_special = array(
                'email' => 'email'
                );


            $objValid->_post_remove = array(
                'confirm_password'
                );


            $objValid->_post_format = array(
                'password' => 'password'
                );

            $email = $objForm->getPost('email');
            $user = $objUser->getByEmail($email);

            if (empty($user)) {
                $objValid->add2Errors('e-mail_not_found');
            }

        }


    // Gather the post data
        $email = $_POST["email"];
        $password = $_POST["password"];
        $confirmpassword = $_POST["confirmpassword"];
        $hash = $_POST["q"];    


    // validate password
    $password = $objForm->getPost('password');
    $confirmpassword = $objForm->getPost('confirmpassword');

    if (!empty($password) && !empty($confirmpassword) && $password != $confirmpassword) {
        $objValid->add2Errors('password_mismatch');
    }

    // Use the same salt from the forgot_password.php file
    $salt = "---blank for demo---";

    // Generate the reset key
    $resetkey = hash('sha512', $salt.$email);

    // Does the new reset key match the old one?
    if ($resetkey == $hash)
    {
        if ($password == $confirmpassword)
        {
            //hash and secure the password
            $password = hash('sha512', $password);

            // Update the user's password
                $query = $conn->prepare('UPDATE clients SET password = :password WHERE email = :email');
                $query->bindParam(':password', $password);
                $query->bindParam(':email', $email);
                $query->execute();
                $conn = null;
            Helper::redirect('/?page=password_changed');
        }
        else
            $objValid->add2Errors('password_mismatch');
    }
    else
        echo "Your password reset key is invalid.";
}


require_once('_header.php'); ?>

<div id="cat_prod"><h1>- CHANGE PASSWORD -</h1></div>

    <br /><br />


    <form action="" method="POST">

        <table cellpadding="0" cellspacing="0" border="0" class="tbl_insert">

            <tr>

                <th>
                    <label for="email">E-mail : *</label>
                </th>

                <td>
                    <?php echo $objValid->validate('e-mail_not_found'); ?>
                    <input type="text" name="email" id="login_email" class="fld" 
                    value="<?php echo $objForm->stickyText('e-mail_not_found'); ?>" /> 
                </td>

            </tr>

            <tr>

                <th>
                    <label for="password">Password : *</label>      
                </th>

                <td>
                    <?php echo $objValid->validate('password'); ?>
                    <?php echo $objValid->validate('password_mismatch'); ?>
                    <input type="password" name="password" id="password" class="fld" value="" />
                </td>

            </tr>

            <tr>

                <th>
                    <label for="confirm_password">Confirm Password : *</label>      
                </th>

                <td>
                    <?php echo $objValid->validate('confirm_password'); ?>
                    <input type="password" name="confirmpassword" id="comfirm_password" class="fld" value="" />
                </td>

            </tr>


            <tr>

                <th>
                     
                </th>

                <td>
                    <label for="change_pass" class="sbm_blue fl_l">
                    <input type="hidden" name="q" value="';
                                if (isset($_GET["q"])) {                        
                                echo $_GET["q"];                            
                            }                           
                                echo '" />
                    <input type="submit" name="ResetPasswordForm" id="btn_login" class="btn" value=" Reset Password " />
                    </label>
                </td>

            </tr>


        </table>

    </form>


<?php require_once('_footer.php'); ?>

可能您有错字。 这样尝试。

<input type="hidden" name="q" value="<?php echo isset($_GET["q"]) ? $_GET["q"]: '' ;?>"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM