davidd07 Posted April 28, 2023 Share Posted April 28, 2023 I have an issue trying to use header("location: admin.php"); on a login.php form. When finally finishing off all the username and password message I can not log in to the admin page, vier the the login. The login page starts with if ($_SERVER["REQUEST_METHOD"] == "POST") { then usual username and password. Changing something else to header("location: http://www.d__.com"); will work. It has something to do with location: ../admin.php or .admin.php I don’t know…. Hope this makes sense. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 28, 2023 Share Posted April 28, 2023 (edited) 19 minutes ago, davidd07 said: I can not log in to the admin page what symptom or error are you getting that leads you to believe that? btw - the only redirect you should have in your post method form processing code should be to the exact same url of the form processing code to cause a get request for that page. this will prevent the browser from trying to resubmit the form data should the user reload the page or navigate away from and back to that page, which will let someone use the developer console network tab to see what the username and password is. if you want the user to be able to go to some other page, provide navigation links. Edited April 28, 2023 by mac_gyver Quote Link to comment Share on other sites More sharing options...
davidd07 Posted April 30, 2023 Author Share Posted April 30, 2023 Yes sorry I have actually fixed it, I deleted the following $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; Then by doing so, I can run the header() again, as what it was doing was not running on localhost. Hope it makes sense. Thanks. Quote Link to comment Share on other sites More sharing options...
geatzo Posted April 30, 2023 Share Posted April 30, 2023 ?> <script type="text/javascript"> window.location.href = 'http://www.google.com.au/'; </script> <?php This does not make the headers work but its a work around. Quote Link to comment Share on other sites More sharing options...
davidd07 Posted May 1, 2023 Author Share Posted May 1, 2023 Thanks so much! Works well. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 1, 2023 Share Posted May 1, 2023 I don't know why the simple header command is not working for you. UNLESS it's the lack of a capital L on 'location'. I have always used it that way and have only seen it that way. And it must be followed by an exit command 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.