商讯信箱
用户名: @
密  码:   注册|忘记密码
登录
个人用户经销商
您的位置:首页 > 技术频道 > 正文

PHP新手上路--与数据库连接

4.4 基于HTTP的Oracle登录

    将以下代码加在PHP页面代码之前以确认Oracle登录。注意你必须正确设定$ SID。

<? 
if(!isset($PHP_AUTH_USER))
{
Header("WWW-authenticate: basic realm=\"$SID\"");
Header("HTTP/1.0 401 Unauthorized");
$title="Login Instructions";
echo "<blockquote>
You are not authorized to enter the site
</blockquote> \n";
exit;
}
else
{
if (!($conn=ora_logon("$PHP_AUTH_USER@$SID",$PHP_AUTH_PW)))
{
Header("WWW-authenticate: basic realm=\"$SID\"");
Header("HTTP/1.0 401 Unauthorized");
$title="Login Instructions";
echo "<blockquote>
You are not authorised to enter the site
</blockquote> \n";
exit;
}
}
?>
1 2 3 4
【内容导航】
第1页: 连接 第2页: 查询
第3页: 显示结果 第4页: 基于HTTP的Oracle登录
©版权所有。未经许可,不得转载。
[责任编辑:阿雪]
[an error occurred while processing this directive]