Home arrow HTML arrow Page 5 - Completing Construction of a Database Form with HTML
HTML

Completing Construction of a Database Form with HTML


In this conclusion to a thirteen-part series on building database forms with HTML, I will talk about the program that receives the data of the transmitted table at the server. I will show you how to do it using CGI and Perl. Recall that the data is actually HTML Form elements sent from the client’s computer.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
October 08, 2008
TABLE OF CONTENTS:
  1. · Completing Construction of a Database Form with HTML
  2. · The Body Element
  3. · The Third Main Row
  4. · The Last Two Rows
  5. · Cgi-bin Directory
  6. · Brief Explanation of the Web Page Code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Completing Construction of a Database Form with HTML - Cgi-bin Directory
(Page 5 of 6 )

Create a directory called cgi-bin in the highest directory of your site. Copy the code below into your text editor, and save the resulting file in the cgi-bin directory; name the file receiveData.pl. This is the code:


use CGI;

 

$cgi = new CGI;


$error = $cgi->cgi_error;


open DESTINATION, ">store.txt";


$cgi->save(DESTINATION);


close DESTINATION;



$filename0 = $cgi->upload('Pi03');

$path0 = ">";

open (OUTFILE,$path0);

while ($bytesread=read($filename0,$buffer,1024))

{

print OUTFILE $buffer;

}

close OUTFILE;


$filename1 = $cgi->upload('Pi13');

$path1 = ">";

open (OUTFILE,$path1);

while ($bytesread=read($filename1,$buffer,1024))

{

print OUTFILE $buffer;

}

close OUTFILE;


$filename2 = $cgi->upload('Pi23');

$path2 = ">";

open (OUTFILE,$path2);

while ($bytesread=read($filename2,$buffer,1024))

{

print OUTFILE $buffer;

}

close OUTFILE;


$filename3 = $cgi->upload('Pi33');

$path3 = ">";

open (OUTFILE,$path3);

while ($bytesread=read($filename3,$buffer,1024))

{

print OUTFILE $buffer;

}

close OUTFILE;


$filename4 = $cgi->upload('Pi43');

$path4 = ">";

open (OUTFILE,$path4);

while ($bytesread=read($filename4,$buffer,1024))

{

print OUTFILE $buffer;

}

close OUTFILE;




if ($error)

{

print $cgi->header(-status=>$error),

$cgi->start_html('Problems'),

$cgi->h2('Request not processed'),

$cgi->strong($error);

exit 0;

}

else

{

print "Content-Type: text/htmlnn";

print "<HTML>n";

print "<HEAD>n";

print "<TITLE>Thanks</TITLE>n";

print "</HEAD>n";

print "<BODY>n";

print "<H1>Thank You</H1>n";

print "<H2>Your message has been sent</H2>n";

print "</BODY>n";

print "</HTML>n";

}


If you are using a Unix, Linux or similar operating system, then precede the above code with the line:

#!/usr/local/bin/perl

which is the path to your Perl interpreter (modify it if necessary).

When you are through, open the web page and link the five image files to the five Input File controls of the web page (using the corresponding Browse buttons). Click the Save button. A new web page should appear, telling you that your message has been received.

Now open the cgi-bin directory. You should see a file called “store.txt.” This file has been created by the receiveData.pl program, which received the data. You should also see five other files, which represent the five different images; more on these later.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials