<html>
<head>
<title>ThaiCreate.Com PHP & Oracle Tutorial</title>
</head>
<body>
<?php
$objConnect = oci_connect("myuser","mypassword","TCDB");
$strSQL = "SELECT * FROM CUSTOMER WHERE CUSTOMERID = '".$_POST["txtCustomerID"]."' ";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$objResult = oci_fetch_array($objParse);
if($objResult)
{
echo "CustomerID already exist.";
}
else
{
$strSQL = "";
$strSQL = "INSERT INTO CUSTOMER ";
$strSQL .="(CUSTOMERID,NAME,EMAIL,COUNTRYCODE,BUDGET,USED) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID"]."','".$_POST["txtName"]."','".$_POST["txtEmail"]."' ";
$strSQL .=",'".$_POST["txtCountryCode"]."','".$_POST["txtBudget"]."','".$_POST["txtUsed"]."') ";
$objParse = oci_parse($objConnect, $strSQL);
$objExecute = oci_execute($objParse,OCI_DEFAULT);
if($objExecute)
{
oci_commit($objConnect); //*** Commit Transaction ***//
echo "Save Done.";
}
else
{
oci_rollback($objConnect); //*** RollBack Transaction ***//
echo "Error Save [".$strSQL."";
}
}
oci_close($objConnect);
?>
</body>
</html>