Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert data into oracle database using a PHP form

547761Nov 22 2006 — edited Dec 19 2007
I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
NOTE: I don't have any problem connecting to the database using php.
Here is the code I'm using:

<?php

// just print form asking for name if none was entered
if( !isset($query)) {
echo "<form action=\"$uri\" method=post>\n";
echo "<p>Enter Name: ";
echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
echo "<br><input type=submit name=submit value=Submit>\n";
echo "</form>\n";
exit;
}

// insert client's name
$query = "INSERT INTO client (name) VALUES ($data)";

// connect to Oracle
$username = "xxxx";
$paswd = "yyyyyy";
$dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
"(HOST=patriot.gmu.edu)(PORT=1521))".
"(CONNECT_DATA=(SID=COSC)))";
$db_conn = ocilogon($username, $paswd, $dbstring);

$stmt = OCIParse($db_conn, $query);
OCIExecute($stmt, OCI_DEFAULT);

OCIFreeStatement($stmt);
OCILogoff($db_conn);

?>

Thanks for your help. I will also appreciate a better was to do it.

Tony
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 16 2008
Added on Nov 22 2006
8 comments
17,715 views