// 主程序 if(!($conn=ora_logon("[email protected]","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("$[email protected]$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; } } ?>