Hello,
Sorry for sending this so many times, but I don't think the attachment
containing the code was sent. So I pasted the code within this message at
the bottom.
I am brand new to Perl and I am trying to get a CGI script for a guestbook
to work and I need some help.
I enter my data on the form, but when I press the submit button, the
guestbook is displayed but the guest information that was entered is not.
Can you take a look at my code and tell me what I am doing wrong. Also, if
you would advise on what the permission settings should be for the files,
that would
help also.
Here is a copy of al the files I am using. If you would please let me know
what you find and what I am doing wrong that would be great. Thank you.
Add.html
========
<HTML>
<HEAD><TITLE>Sign My GuestBook</TITLE></HEAD>
<BODY>
<H2 ALIGN=CENTER>Sign My Guest Book</H2>
<FORM METHOD="POST" ACTION="/cgi-bin/addguest.cgi">
<table cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td>Your name:</td>
<td><INPUT type=text size=60 maxlength=256 name="name"></td>
</tr>
<tr>
<td>E-mail address:</td>
<td><INPUT type=text size=60 maxlength=256 name="address"></td>
</tr>
<tr>
<td>City:</td>
<td><INPUT type=text size=60 maxlength=256 name="city"></td>
</tr>
<tr>
<td>Country:</td>
<td><INPUT type=text size=60 maxlength=256 name="country"></td>
</tr>
<tr valign="top">
<td>Comments:</td>
<td><TEXTAREA rows=9 cols=51 name="comments"></TEXTAREA></td>
</tr>
<tr>
<td colspan="2" align="center">
<INPUT type="submit" value="Submit"> <INPUT type="reset" value="Reset">
</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
addguest.cgi
============
#!/usr/bin/perl
#open database in append mode
open(FILE,">>data.txt") || die "Can't find database\n";
#add form data to end of file
print FILE
"$indata{'name'}|$indata{'address'}|$indata{'city'}|$indata{'country'}|$indata{'comments'}\n";
#close the database file
close(FILE);
#run the guestbook.cgi to view the database contents
print "Location:http://jmdtechnologies.com/cgi-bin/guestbook.cgi\n\n";
#end of program
guestbook.cgi
=============
#!/usr/bin/perl
print "Content-type:text/html\n\n";
#open the database
open(FILE,"data.txt") || die "Can't find database\n";
#store database contents in an array and close file
@indata = <FILE>;
close(FILE);
#start web page, produce first row of table
print <<"PrintTag";
<html>
<head>
<title>Our Guestbook</title>
</head>
<body>
<center>
<h1>Our Guestbook</h1>
</center>
PrintTag
#use a foreach loop to process each record in the array
foreach $i (@indata)
{
#remove hard return character from each record
chomp($i);
#split fields on pipe character
#assign a variable name to each of the fields
($name,$address,$city,$country,$comments) = split(/\|/,$i);
#add a new row to the table for each record
print " Name: $name";
print "<br>";
print " Email: $address";
print "<br>";
print " City:
$city";
print "<br>";
print " Country: $country";
print "<br>";
print "Comments: $comments";
print "<br>";
print "<hr>";
#close the loop
}
#close the HTML document
print "</body></html>";
#end of program
_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]