Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

PHP form not inserting into Oracle Database

This is similar to my MySql query a few days ago. I have this form set up to insert into an Oracle 9 database. I haven't messed with .htaccess or anything, and it never seems to enter the block where it puts data into the database. I tried the same code with pre-defined data values and it worked fine.



<HTML>
<TITLE>ORACLE form</TITLE>
<BODY>

<?php
if($_POST['submit'] == "Submit")
{
      echo "inside this block";   /* checks if it is inside the block */
      $iDBConn = ocilogon("DBNAME", "DB_PASSWORD", "DB_SERVER");
      if (!$iDBConn)
            echo ('fail');
      $strID;
      $strTESTDATA;
      
      $insertentries = "insert into TEST values ( :strID, :strTESTDATA )";
      $iStatement = @OCIParse($iDBConn, $insertentries);
      
      @OCIBindByName($iStatement, ':strID', &$_POST['strID']);
      @OCIBindByName($iStatement, ':strTESTDATA', &$_POST['strTESTDATA']);
      @OCIExecute($iStatement, OCI_DEFAULT);
      
      $arrError = OCIError($iStatement);
      if ($arrError['code'])
              { print $arrError['message'];
                  OCIRollback($iDBConn);
                  exit; }
      
      OCICommit($iDBConn);
}
?>

<?php
echo "
<form name=\"test\" method=\"post\" action=\"form.php\">
<input type=\"hidden\" name=\"strID\" value=\"null\">
testdata: <input type=\"text\" name=\"strTESTDATA\">
<input type=\"submit\" name=\"Submit\" value=\"Submit\">
</form>";
?>

</BODY>
</HTML>
0
TXLonghorn
Asked:
TXLonghorn
  • 3
  • 2
1 Solution
 
ThGCommented:

is it failing this condition?

if($_POST['submit'] == "Submit")

if so, adding a var_dump($_POST) might help to see what data you have to work with..
0
 
TXLonghornAuthor Commented:
Where exactly do I add it?
0
 
ThGCommented:

between <?php and if ( ...
0
 
TXLonghornAuthor Commented:
Thanks for the info about the dump command... found two bugs:

in           if($_POST['submit'] == "Submit")

'submit' should have been 'Submit'

and        value=\"null\"

should have been value=\"\"

Something tells me the var_dump command will make debugging a whole lot easier for me.
0
 
ThGCommented:
yes it does, var_dump and print_r (for arrays) are very useful commands.
bye
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now