Hi guys. I'm new to this board and don't know anything about PHP. So I apologize if my questions are too basic for this board.
I am just trying to password protect a webpage. I downloaded a script from: I followed the instruction, however I am getting the following errors:
Notice: Undefined index: SERVER_ADMIN in C:\Inetpub\ on line 12
Notice: Undefined variable: PHP_AUTH_USER in C:\Inetpub\ on line 16
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\ in C:\Inetpub\ on line 17
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\ in C:\Inetpub\ on line 18
I have IIS and PHP set up.
Could any of you tell me what I need to do to make this work? I am pasting the script below.
Thanks a bunch!
//===============================
//put the following line in the PHP page you want to protect:include ("./p_protect.php");
//===============================
<?php
$selfSecure = 1;
$shellUser = "demo";
$shellPswd = "demo";
$adminEmail = "jislam@unitrin.com";
$fromEmail = $HTTP_SERVER_VARS["SERVER_ADMIN"];
$Version = "Your details here (for example The Webmaster - webmaster@xxx.com)";
if($selfSecure){
if (($PHP_AUTH_USER!=$shellUser)||($PHP_AUTH_PW!=$shellPswd)) {
Header(' Basic realm="MCE Web ADMIN only!"');
Header('HTTP/1.0 401 Unauthorized');
echo "<html>
<head>
<title>Error - Access Denied</title>
</head>
<h1>Access denied</h1>
A warning message has been sent to the webmaster. Your IP address has also been recorded
<hr>
<em>$Version</em>";
if(isset($PHP_AUTH_USER)){
$warnMsg ="
Somebody tried to access the script on: ["HTTP_HOST"]."$PHP_SELF
using the wrong username or password:
Date: ".date("Y-m-d H:i:s")."
IP: ".$HTTP_SERVER_VARS["REMOTE_ADDR"]."
User Agent: ".$HTTP_SERVER_VARS["HTTP_USER_AGENT"]."
username used: $PHP_AUTH_USER
password used: $PHP_AUTH_PW
";
mail($adminEmail,"Unauthorized Access",$warnMsg,
"From: $fromEmail\nX-Mailer:$Version AutoWarn System");
}
exit;
}
}
if(!$oCols)$oCols=$termCols;
if(!$oRows)$oRows=$termRows;
?>
I am just trying to password protect a webpage. I downloaded a script from: I followed the instruction, however I am getting the following errors:
Notice: Undefined index: SERVER_ADMIN in C:\Inetpub\ on line 12
Notice: Undefined variable: PHP_AUTH_USER in C:\Inetpub\ on line 16
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\ in C:\Inetpub\ on line 17
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\ in C:\Inetpub\ on line 18
I have IIS and PHP set up.
Could any of you tell me what I need to do to make this work? I am pasting the script below.
Thanks a bunch!
//===============================
//put the following line in the PHP page you want to protect:include ("./p_protect.php");
//===============================
<?php
$selfSecure = 1;
$shellUser = "demo";
$shellPswd = "demo";
$adminEmail = "jislam@unitrin.com";
$fromEmail = $HTTP_SERVER_VARS["SERVER_ADMIN"];
$Version = "Your details here (for example The Webmaster - webmaster@xxx.com)";
if($selfSecure){
if (($PHP_AUTH_USER!=$shellUser)||($PHP_AUTH_PW!=$shellPswd)) {
Header(' Basic realm="MCE Web ADMIN only!"');
Header('HTTP/1.0 401 Unauthorized');
echo "<html>
<head>
<title>Error - Access Denied</title>
</head>
<h1>Access denied</h1>
A warning message has been sent to the webmaster. Your IP address has also been recorded
<hr>
<em>$Version</em>";
if(isset($PHP_AUTH_USER)){
$warnMsg ="
Somebody tried to access the script on: ["HTTP_HOST"]."$PHP_SELF
using the wrong username or password:
Date: ".date("Y-m-d H:i:s")."
IP: ".$HTTP_SERVER_VARS["REMOTE_ADDR"]."
User Agent: ".$HTTP_SERVER_VARS["HTTP_USER_AGENT"]."
username used: $PHP_AUTH_USER
password used: $PHP_AUTH_PW
";
mail($adminEmail,"Unauthorized Access",$warnMsg,
"From: $fromEmail\nX-Mailer:$Version AutoWarn System");
}
exit;
}
}
if(!$oCols)$oCols=$termCols;
if(!$oRows)$oRows=$termRows;
?>