Logout & Email Problems
| From: | vinkee | Date: | Tue, 04 Nov 2003 08:56:40 +0000 |
| Subject: | Logout & Email Problems | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-12195@lists.php.net to get a copy of this message | ||
Dear all,
I would like to check with you guys whether any comments will be given.
1.. I have created an index login page with the following code.
<?php
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="Security Login!"');
header('HTTP/1.0 401 Unauthorized');
echo '<br><br><div align="center"><font
color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">Sorry, This site
is strictly confidential !</font></div><br><br>';
echo ' ';
echo '<div align="center"><font color="#FF0000"
face="Verdana, Arial, Helvetica, sans-serif">You are not authorized to access this
site....., please check with your administrator.</font></div>';
echo '<br><br><br><br><br><div
align="center"><font color="#000000" face="Verdana, Arial, Helvetica,
sans-serif">Copyright Tecsys Product ® 2003. All Rights
Reserved</font></div><br><br>';
exit;
} else if (isset($PHP_AUTH_USER)) {
mysql_connect("localhost", "username", "password")
or die ("Unable to connect to database.");
// select database on MySQL server
mysql_select_db("sales")
or die ("Unable to select database.");
// Formulate the query
$sql = "SELECT *
FROM user
WHERE username='$PHP_AUTH_USER' and
password='$PHP_AUTH_PW'";
// Execute the query and put results in $result
$result = mysql_query($sql);
// Get number of rows in $result. 0 if invalid, 1 if valid.
while ($row = mysql_fetch_array($result)) {
$PHP_AUTH_USER = $row['username'];
$PHP_AUTH_PW = $row['password'];
$name = $row['name'];
}
$num = mysql_numrows($result);
if ($num == "0") {
header('WWW-Authenticate: Basic realm="Security Login!"');
header('HTTP/1.0 401 Unauthorized');
echo '<br><br><div align="center"><font
color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">Sorry, This site
is strictly confidential !</font></div><br><br>';
echo ' ';
echo '<div align="center"><font color="#FF0000"
face="Verdana, Arial, Helvetica, sans-serif">You are not authorized to access this
site....., please check with your administrator.</font></div>';
echo '<br><br><br><br><br><div
align="center"><font color="#000000" face="Verdana, Arial, Helvetica,
sans-serif">Copyright Tecsys Product ® 2003. All Rights
Reserved</font></div><br><br>';
exit;
} else
if ($num != "0") {
session_start();
session_register('user');
$user = "yes";
session_register('user_login');
$user_login = "$name";
header("Location:content.php");
exit;
}
}
?>
My session will register as above, but for my logout / log off page..the code as below:
<?
session_start();
session_unset($user);
session_unset($user_login);
session_destroy();
header("Location: http://192.168.1.1/sales/logout_msg.php");
?>
After logout, i try to login again, but it straight away go in to the content page without asking me
to enter the username and password. May I know what's wrong ? Any help ? thanks,
Besides, my second problem is the mail function. I have coming out a script "mail () "
function. Even the script the is running but no email received, may i know other than mail ()
function, anyway to do email scripting by using PHP ?
thanks in advance,
Regards,
Winson Kee