Jump to content

php problems (Undefined index: PHP_SELF)


chris_rulez001

Recommended Posts

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

Link to comment
Share on other sites

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.