?
Solved

PHP form not inserting into Oracle Database

Posted on 2003-10-31
5
Medium Priority
?
229 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 400 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …
Suggested Courses

752 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