-1

I am writing a php file, where I want to display a different content within an existing html element when a get variable is set.

Now what i want is to set the word " Password Reset Was Success" instead of "Enter your Email to reset the password" or add a new <p> tag containing the required words by hiding current <p> tag when the GET variable is set. But I have no idea of how to do this. I checked different times, but I failed. I really appreciate if some one can help me to do this.

here is my code.

 <div class="login-box-body">
<!--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.';
        } ?>
    </div>
3
  • You can do this using js.innerHtml method. Commented Jul 2, 2020 at 11:02
  • @HamzaAbdaoui, but it use onload() function, Waht I want is to change the content without any clicks, once the GET variable is set Commented Jul 2, 2020 at 11:07
  • Possible duplicate of Conditional Statements in PHP code Between HTML Code Commented Jul 2, 2020 at 11:31

1 Answer 1

-1

You just need to wrap inside if condition:

<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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.