// 主程序 if(!($conn=ora_logon("user@SID","password"))) { echo "Error: Cannot connect to database/n"; exit; } $qry="SELECT deptno /"Dept/" ,empno /"Emp/" ,empnm /"Name/" ,salary /"Salary/" FROM employee ORDER BY 1,2"; exequery($qry); ora_logoff($conn); ?> (译者注:以上代码段缺少注释,请读者参考PHP Manual的Oracle数据库函数部分)
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; } } ?>