Mark2024 Posted November 19 Share Posted November 19 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'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/325581-form-help/ Share on other sites More sharing options...
requinix Posted November 20 Share Posted November 20 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 } Quote Link to comment https://forums.phpfreaks.com/topic/325581-form-help/#findComment-1641037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.