Things You'll Need:
- Text editor
- Access to Oracle with user name and password
-
Step 1
Create the web page in HTML. Make sure the page includes two text input fields named "user" and "password." Set the form action to call "input.cgi" from the cgi-bin on your server. Save the HTML as "info.html."
-
Step 2
Create the server side script. For PERL to speak to a database, you must use the DBI module. The following script shows how to connect to the database:
#!/usr/bin/perl -w
use CGI;
use DBI;
print "Content-type: text/html\n\n";
$cgi = CGI->new();
$user = $cgi->param('user');
$password = $cgi->param('password');
$dbh = DBI->connect( "dbi:Oracle:your_Database_name", "your_username", "your_password" )
or die "Can't connect to Oracle database: $DBI::errstr\n";
You must get the values for "your_Database_name," "your_username," and "your_password" from your server administrator. For this tutorial, it is assumed you already have this information. -
Step 3
Write the SQL. To do this, you must have a table set up in Oracle that can receive the two fields. Call the table "user_auth" and make sure it has a column called "user" and another one called "pwd." The following SQL statement will insert the data into the table:
$sqlstatement="INSERT INTO user_auth VALUES ('$user','$password')";
$sth=$dbh->prepare($sqlstatement);
$sth->execute || print $sqlstatement; -
Step 4
Confirm the data have been entered by including a print command. To do this, add the following line of code to the end of the program:
print "<h3>Information accepted</h3>";
If this does not print out, then you can be sure the information was not sent. You must go back and check the database settings. Save the script as "input.cgi." -
Step 5
Upload the HTML and CGI files to the server. The HTML must go in docs area, and the CGI must be uploaded to the cgi-bin.
-
Step 6
Execute the program. Do this by opening the HTML document in a browser and entering some mock information. Once you submit it, you should see the confirmation printout. If you see the printout, the information has been sent to the database.












