将内容替换为php代码中的html元素

时间:2020-07-02 10:57:45

标签: php html

我正在编写一个php文件,当设置了get变量时,我想在其中显示现有html元素中的其他内容。

现在,我要设置的是设置“密码重置成功”一词,而不是“输入您的电子邮件以重置密码”,或者通过隐藏当前的{{1}来添加包含所需单词的新<p>标签}标签,设置GET变量时。但是我不知道该怎么做。我检查了不同的时间,但失败了。我真的很感谢有人能帮助我做到这一点。

这是我的代码。

<p>

1 个答案:

答案 0 :(得分:-1)

如果条件满足,您只需要包装在里面即可

<div class="login-box-body">
    <?php if(isset($_GET['the_get_var_you_are_expecting'])){ ?>
        <p class="success">Password Reset Was Success</p>

    <?php } else { ?>
        <!--Want to replace this text as Password Reset Was Success or add a new <p> tag containing  the required words by hiding current <p> tag -->
        <p class="login-box-msg">Enter your Email to reset the password</p>

        <?php require '_inc/msg.php' ?>

        <!--  Check if GET variable is set or not -->
        <?php if (isset($_GET['code'])) {

            echo '<style>.formPsw{ display:none;}</style>';

        } ?>

        <form action="" method="post" class="formPsw">
            <div class="form-group has-feedback emailBox" >
                <input type="email" name="email" class="form-control" placeholder="Email" data-validation="email required">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                </div>
                <!-- /.col -->
                <div class="col-xs-4 sendEmailBtn">
                    <input type="submit" name="send" class="btn btn-primary btn-block btn-flat" value="send"/>
                </div>
                <!-- /.col -->
            </div>
        </form>
        <?php if (!empty($_POST['send'])) {
            echo 'Please check your email ('.$_POST['email'].'). We send password reset link to your email.';
        } ?>

    <?php } ?>
</div>