oz11 Posted January 19 Share Posted January 19 Hey.. i have this code. Though the form is shown on the page after entering the password, and its gone as desired when I reload the page.. how do I get it to not show on the next page before having to reload?? $room = $_GET['room']; $salt = 444422; if($_SESSION['in_chat']!=$room.$salt){ $stmt = $pdo->prepare("SELECT pass_code FROM `chatrooms` WHERE name =?"); $stmt->execute([$_GET['room']]); $pass_checker = $stmt->fetch(); $hash = $pass_checker['pass_code']; if($hash!=null AND $_SESSION['in_chat']!=$room.$salt){ ?> <form action="" method="POST" name="passcheck"> <input type="password" name="password_"><input type="hidden" name="chat_pass"><input type="submit" value="Submit"></form> <?php } if(isset($_POST['password_'])) { if(!password_verify($_POST['password_'], $pass_checker['pass_code'])) { echo "Wrong password"; exit; } else{ $_SESSION['in_chat'] == $room.$salt; } } else{ exit(); } } Note: "salt" is just there so i can test the sessions without resetting. Thanks! Quote Link to comment Share on other sites More sharing options...
Andou Posted January 19 Share Posted January 19 Dunno how helpful this is, but if I were you I would put all the relevant PHP code before the HTML so I didn't keep breaking in and out of it. I suppose the reason why the form is showing on the next page is that it's in the HTML, but someone with more experience may have a better solution. Quote Link to comment 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.