Jump to content

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/316216-using-header-on-php-does-not-work/
Share on other sites

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 by mac_gyver

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.