Jump to content

Recommended Posts

Hello Guys im using the code to update my password in my login system my question is how do i hide the form once it has been submitted so it just shows the echo message?

<?php include('styles/top.php'); ?>

<div id="left">
        
        <img src="images/john.png" height="600px" width="300px" />
        
    </div>
    
     <div id="right">
    
        <div id="view_box">
            <ul>
                <li><img src="images/1.png" /></li>
                <!-- <li><img src="pics/2.jpg" /></li> -->
                <!-- <li><img src="pics/3.jpg" /></li> -->
            </ul>
        </div>
        
        <div id="button">
            <ul>
                <!-- <li><button class="button" scroll_value="0">*</button></li> -- >
                <!-- <li><button class="button" scroll_value="600">*</button></li> -->
                <!-- <li><button class="button" scroll_value="1200">*</button></li> -->
            </ul>
        </div>
       
       
       
        <hr />
        
        
        <?php
        
        if (($user_level !=1 && $user_level !=2)){
            echo " 
            
            Coming Soon
            
            ";
         
            
        } else {
            
       if(isset($_POST['update']))
{
  $n_password = md5($_POST['n_password']);

  $c_password = md5($_POST['c_password']);

    if($c_password === $n_password)
  {
    
     $sql="update customers set password='$n_password' where
        username='$username'";
        
     $res=mysqli_query($con,$sql);
     
     if($res)
     {
         //Password Successfully Changed.
        echo "Password Has Been Changed";
     }
     else
     {
         //Sorry, Something went wrong, Please Try Again.
         echo "Sorry, Something went wrong, Please Try Again.";
     }
  }
  else
  {
      //Password do not Match.
     echo "Passwords do not match.";
}
}
            
    ?>
        
        <h2>Change Your Password</h2>
        
        <form action="" method="post">
            <input type="password"" name="n_password" placeholder="Enter new username" required>
 
     <input type="password" name="c_password" placeholder="Enter confirm password" required>
     
     <input type="submit" value="Submit" name="update">
        </form>
    

        
      <?php
        } 
        ?>
        
    </div>

<?php include('styles/bottom.php'); ?>

 

Link to comment
https://forums.phpfreaks.com/topic/325581-form-help/
Share on other sites

The simple answer is probably also obvious: if you don't want to show the form under certain conditions (like after the form was submitted successfully) then don't show the form under those conditions.

There's a bunch of different ways to go about it, but the one thing they all have in common is that there's an if statement that checks whether or not you want to show the form, and if you do then it shows the form. For example,

if (/* show the form */) { ?>

(the form)

<?php }

 

Link to comment
https://forums.phpfreaks.com/topic/325581-form-help/#findComment-1641037
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.