如何在PHP中使用Oracle数据库(4)
程序员文章站
2022-08-11 15:52:33
利用oci向数据表 'email_info' 输入数据 同上,只不过用oci来写 相关php代码: if ($submit == "clic...
利用oci向数据表 'email_info' 输入数据
同上,只不过用oci来写
相关php代码:
if ($submit == "click"){
// the submit button was clicked!
// get the input for fullname and email then store it in the database.
putenv("oracle_sid=orasid");
$connection = ocilogon ("username","password");
if ($connection == false){
echo ocierror($connection)."
";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$cursor = ociparse ($connection, $query);
if ($cursor == false){
echo ocierror($cursor)."
";
exit;
}
$result = ociexecute ($cursor);
if ($result == false){
echo ocierror($cursor)."
";
exit;
}
ocicommit ($connection);
ocilogoff ($connection);
}
else{
echo '
<form action=insert.php method=post>
请输入姓名
<input name=fullname></input>
请输入 email 地址
<input name=email></input>
<input name=submit type=submit value=click></input>
</form>
';
}
?>
对了,这段脚本必须存为insert.php,因为在调用的页面中指定insert.php为表单处理程序
同上,只不过用oci来写
相关php代码:
if ($submit == "click"){
// the submit button was clicked!
// get the input for fullname and email then store it in the database.
putenv("oracle_sid=orasid");
$connection = ocilogon ("username","password");
if ($connection == false){
echo ocierror($connection)."
";
exit;
}
$query = "insert into email_info values ('$fullname', '$email')";
$cursor = ociparse ($connection, $query);
if ($cursor == false){
echo ocierror($cursor)."
";
exit;
}
$result = ociexecute ($cursor);
if ($result == false){
echo ocierror($cursor)."
";
exit;
}
ocicommit ($connection);
ocilogoff ($connection);
}
else{
echo '
<form action=insert.php method=post>
请输入姓名
<input name=fullname></input>
请输入 email 地址
<input name=email></input>
<input name=submit type=submit value=click></input>
</form>
';
}
?>
对了,这段脚本必须存为insert.php,因为在调用的页面中指定insert.php为表单处理程序
上一篇: 用PHP连接Oracle for NT 远程数据库
下一篇: 人大复印资料处理程序_补充篇