chris_rulez001 Posted May 22, 2007 Share Posted May 22, 2007 hi ive made an admin panel and i tried to password protect it and im getting problems. i have got the session start at the very top of the page. the php code: <?php if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == 1){ //They are logged in. echo "Congratulations. You have logged in correctly!"; echo "<center>"; echo "<h2><you><b>"; echo "Chatroom Administration"; echo "</b></you></h2>"; echo "</center>"; echo "<A href='banip.php'>Ban IPS</a> | <A href='unbanip.php'>Unban IP</a> | <A href='editdelete.php'>Edit/Delete messages</a><br>"; }else{ if(isset($_POST['submit'])){ //They have posted something! $username = "Administrator"; $password = "buzzer2242"; if($_POST['pass'] == $password && $_POST['user'] == $username){ //They have sent us the correct login information! $_SESSION['loggedin'] = "1"; $_SESSION['user'] = $_POST['user']; header('Location: '.$_SESSION['PHP_SELF']); //The user has been redirected back to the main page and it should say they they have logged in! }else{ //They failed to send us the correct username or password! die('Incorrect username or password!'); } }else{ echo "<form method=post action=".$_SERVER['PHP_SELF'].">Username: <input type=text name=user><br><br>Password: <input type=password name=pass><br><br><input type=submit name=submit value=\"Login!\"></form>"; } } ?> problems orrcuring: Notice: Undefined index: PHP_SELF in /www/1111mb.com/c/h/are/chrisrulez/htdocs/chat/admin.php on line 31 Warning: Cannot modify header information - headers already sent by (output started at /www/1111mb.com/c/h/are/chrisrulez/htdocs/chat/admin.php:12) in /www/1111mb.com/c/h/are/chrisrulez/htdocs/chat/admin.php on line 31 Quote Link to comment https://forums.phpfreaks.com/topic/52469-php-problems-undefined-index-php_self/ Share on other sites More sharing options...
ToonMariner Posted May 22, 2007 Share Posted May 22, 2007 I think you menat to use $_SERVER['PHP_SELF'] insetad of $_SESSION['PHP_SELF'] here... $_SESSION['loggedin'] = "1"; $_SESSION['user'] = $_POST['user']; header('Location: '.$_SESSION['PHP_SELF']); Quote Link to comment https://forums.phpfreaks.com/topic/52469-php-problems-undefined-index-php_self/#findComment-258891 Share on other sites More sharing options...
chris_rulez001 Posted May 22, 2007 Author Share Posted May 22, 2007 ive editted the section it now looks like: $_SERVER['loggedin'] = "1"; $_SERVER['user'] = $_POST['user']; header('Location: '.$_SERVER['PHP_SELF']); but there is a problem it doesnt bring up the login form it just brings up what i want to protect Quote Link to comment https://forums.phpfreaks.com/topic/52469-php-problems-undefined-index-php_self/#findComment-258899 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.