Solved

PHP form not inserting into Oracle Database

Posted on 2003-10-31
5
227 Views
Last Modified: 2013-12-12
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
Comment
Question by:TXLonghorn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 100 total points
ID: 9660555

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
 

Author Comment

by:TXLonghorn
ID: 9660598
Where exactly do I add it?
0
 
LVL 14

Expert Comment

by:ThG
ID: 9660624

between <?php and if ( ...
0
 

Author Comment

by:TXLonghorn
ID: 9660712
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
 
LVL 14

Expert Comment

by:ThG
ID: 9660795
yes it does, var_dump and print_r (for arrays) are very useful commands.
bye
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question