-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>
Kash
  • 329
  • 3
  • 15
  • You can do this using [js.innerHtml](https://www.w3schools.com/jsref/prop_html_innerhtml.asp) method. – Hamza Abdaoui Jul 02 '20 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 – Kash Jul 02 '20 at 11:07
  • Possible duplicate of [Conditional Statements in PHP code Between HTML Code](https://stackoverflow.com/questions/3812526/conditional-statements-in-php-code-between-html-code) – MrUpsidown Jul 02 '20 at 11:31

1 Answers1

-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>
Oussama
  • 595
  • 5
  • 16