<html>
<head>
<title>ThaiCreate.Com PHP & Access Tutorial</title>
</head>
<body>
<?php
$objConnect = odbc_connect("mydatabase","","") or die("Error Connect to Database");
$strSQL = "SELECT * FROM customer WHERE CustomerID = '".$_POST["txtCustomerID"]."' ";
$objExec = odbc_exec($objConnect, $strSQL);
$objResult = odbc_fetch_array($objExec);
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"]."') ";
$objExec = odbc_exec($objConnect, $strSQL);
if($objExec)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
}
odbc_close($objConnect);
?>
</body>
</html>