How to use Oracle Database in PHP (3) _php Basics

Source: Internet
Author: User
Using ORA to enter data into the datasheet ' Email_info '

When the user browses this script, displays a form that consists of a name, an email input field, and when the user adds a good data click Submit, the script will save the name and email to the ' email_info ' datasheet.

Related PHP Code:


if ($submit = = "click") {
The Submit button was clicked!
Get the input for fullname and email then store it in the database.
PUTENV ("Oracle_sid=orasid");

$connection = Ora_logon ("username", "password");
if ($connection = = False) {
echo Ora_errorcode ($connection). ":". Ora_error ($connection). "
";
Exit
}

$cursor = Ora_open ($connection);
if ($cursor = = False) {
echo Ora_errorcode ($connection). ":". Ora_error ($connection). "
";
Exit
}

$query = "INSERT into email_info values (' $fullname ', ' $email ')";
$result = Ora_parse ($cursor, $query);
if ($result = = False) {
echo Ora_errorcode ($cursor). ":". Ora_error ($cursor). "
";
Exit
}

$result = Ora_exec ($cursor);
if ($result = = False) {
echo Ora_errorcode ($cursor). ":". Ora_error ($cursor). "
";
Exit
}

Ora_commit ($connection);
Ora_close ($cursor);
Ora_logoff ($connection);
}
else{
Echo '


<form action=insert.php method=post>

Please enter your name
<input name=fullname> </INPUT>

Please enter your email address
<input name=email> </INPUT>

<input name=submit type=submit value=click> </INPUT>

</FORM>


';
}

?>


Yes, this script must be saved as insert.php because the insert.php is specified as the form handler in the calling page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.