// 主程序 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; } } ?>