zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

如何在PHP中使用Oracle数据库(4)

OraclePHP数据库 使用 如何
2023-06-13 09:13:43 时间
利用OCI向数据表"email_info"输入数据

同上,只不过用OCI来写  

相关PHP代码:


if($submit=="click"){
  //Thesubmitbuttonwasclicked!
  //Gettheinputforfullnameandemailthenstoreitinthedatabase.
  PutEnv("ORACLE_SID=ORASID");

  $connection=OCILogon("username","password");
  if($connection==false){
    echoOCIError($connection)."
";
    exit;
  }

  $query="insertintoemail_infovalues("$fullname","$email")";
  $cursor=OCIParse($connection,$query);
  if($cursor==false){
    echoOCIError($cursor)."
";
    exit;  
  }

  $result=OCIExecute($cursor);
  if($result==false){
    echoOCIError($cursor)."
";
    exit;
  }

  OCICommit($connection);
  OCILogoff($connection);
}
else{
  echo"


     <FORMaction=insert.phpmethod=post>

    请输入姓名
    <INPUTname=fullname></INPUT>

    请输入Email地址
    <INPUTname=email></INPUT>

    <INPUTname=submittype=submitvalue=click></INPUT>         

    </FORM>

     
  ";
}

?>  


对了,这段脚本必须存为insert.php,因为在调用的页面中指定insert.php为表单处理程序