40 users online (0 members and 40 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 3
  2. Replies: 1
  3. trying to write to textarea based on user input    Forum: Javascript Forum
    Replies: 5
  4. Replies: 1
  5. Replies: 2
  1. #1
    esgwyd1's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2004
    Posts
    1

    CGI form input doesn't write to text file

    #!C:/Perl/bin/perl.exe -w


    use CGI::Carp qw( fatalsToBrowser );
    use CGI;

    my $IN = new CGI;
    CGI::ReadParse(*in);

    print $IN->header();
    print $IN->param('parameter_name');

    # Process form if submitted; otherwise display it
    if ( $IN->param("submit") )
    {
    process_form ( );
    }
    else
    {
    display_form ( );
    }

    sub process_form
    {
    if ( validate_form ( ) )
    {
    print <<END_HTML;
    <html><head><title>Thank You</title></head>
    <body>
    Thank you for your metadata entry.<br>
    The new metadata information has been sent to Metadata Systems Engineering for review.<br>
    <A HREF="http://isd.kodak.com/imgscience/best_practices/metadata/md_regstry/index.html">Return to Registry</A>
    </body></html>

    END_HTML
    }
    }

    sub validate_form
    {
    my $insuranceno = $IN->param("insuranceno");
    my $firstname = $IN->param("firstname");
    my $lastname = $IN->param("lastname");
    my $email = $IN->param("email");
    my $phoneno = $IN->param("phoneno");
    my $building = $IN->param("building");
    my $floor = $IN->param("floor");
    my $plant = $IN->param("plant");
    my $project = $IN->param("project");
    my $category = $IN->param("category");
    my $metadataname = $IN->param("metadataname");
    my $metadatadefinition = $IN->param("metadatadefinition");

    my $error_message = "";

    $error_message .= "insurance number, " if ( !$insuranceno );
    $error_message .= "first name, " if ( !$firstname );
    $error_message .= "last name, " if ( !$lastname );
    $error_message .= "email address, " if ( !$email );
    $error_message .= "phone number, " if ( !$phoneno );
    $error_message .= "project, " if ( !$project );
    $error_message .= "category, " if ( $category eq "Select One" );
    $error_message .= "metadata name, " if ( !$metadataname );
    $error_message .= "metadata definition." if ( !$metadatadefinition );


    if ( $error_message )
    {
    display_form ( $error_message, $insuranceno, $firstname, $lastname, $email, $phoneno, $building, $floor, $plant, $project,

    $category, $metadataname, $metadatadefinition );
    return 0;
    }
    else
    {
    return 1;
    }

    }

    sub display_form
    {
    my $error_message = shift;
    my $insuranceno = shift;
    my $firstname = shift;
    my $lastname = shift;
    my $email = shift;
    my $phoneno = shift;
    my $building = shift;
    my $floor = shift;
    my $plant = shift;
    my $project = shift;
    my $category = shift;
    my $metadataname = shift;
    my $metadatadefinition = shift;

    my $category_html = "";
    my @category_opts = ( "Select One", "CaptureConditions", "CaptureDevice", "DigitalProcess", "ImageContainer", "IntellectualProperty

    ", "OutputOrder", "SceneContent");

    foreach my $category_option ( @category_opts )
    {
    $category_html .= "<option value=\"$category_option\"";
    $category_html .= " selected" if ( $category_option eq $category );
    $category_html .= ">$category_option</option>";
    }


    # Display the form
    print <<END_HTML;
    <html>
    <head><title>Submission of New Metadata</title></head>
    <body><font size = "4" face = "Times New Roman">

    <table><tr><p><td align="RIGHT" WIDTH="520"><font size = "3" color="#AD0000">Welcome to Metadata Engineering's New Metadata Submission web

    site. Please fill in the information below. When you are done, click on the Submit button. The information you have entered will be recorded

    in a database. Email verification will also be sent to Metadata Engineering as well as to you. You will be contacted at a later date if

    there are any questions concerning your entry.</font></td></p></tr>

    <td align="RIGHT"><font size = "4" face = "Times New Roman"><b> Enter the following contact information: </b></font></td></tr>

    <form action="form_validation.cgi" method="post">
    <input type="hidden" name="submit" value="Submit">

    <p><td align="RIGHT" WIDTH="520"><font color="red"><i><b>$error_message<br></td></font></i></b></p>

    <tr><td align="RIGHT"><i>Items with a check <IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16"

    BORDER="0" ALIGN="ABSMIDDLE"> are required.</i></td></tr>
    <tr><td align="RIGHT">&nbsp</td></tr>\n
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Insurance Number <input type="text" name="insuranceno" value="$insuranceno" SIZE="6" MAXLENGTH="6"></td></tr>
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">First Name <input type="text" name="firstname" value="$firstname" SIZE="35" MAXLENGTH="100"></td></tr>
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Last Name <input type="text" name="lastname" value="$lastname" SIZE="35" MAXLENGTH="100"></td></tr>
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Email Address <input type="text" name="email" value="$email" SIZE="35" MAXLENGTH="100"></td></tr>
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Phone No.<input type="text" name="phoneno" value="$phoneno"></td></tr>
    <tr><td align="RIGHT">Building <input type="text" name="building" value="$building"></td></tr>
    <tr><td align="RIGHT">Floor <input type="text" name="floor" value="$floor"></td></tr>
    <tr><td align="RIGHT">Plant <input type="text" name="plant" value="$plant"></td></tr>
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Project <input type="text" name="project" value="$project" SIZE="35" MAXLENGTH="100"></td></tr>\n
    <tr><td align="RIGHT">&nbsp</td></tr>\n

    <tr><td align="RIGHT"><font size = "4"><b> Metadata Information to be submitted: </b></font></td></tr>
    <tr><td align="RIGHT">&nbsp</td></tr>\n
    <tr><td align="RIGHT"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0" ALIGN="

    ABSMIDDLE">Category <select name="category">$category_html</select></td></tr><br>
    <tr><td align="right" CLASS="body1"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0"

    ALIGN="ABSMIDDLE">Metadata Name <input type ="text" name="metadataname" value="$metadataname" SIZE="50" MAXLENGTH="100"><br></td></tr>
    <tr><td align="RIGHT" valign="TOP"><IMG SRC="http://150.220.3.194:8081/icons/check.gif" HEIGHT="16" WIDTH="16" BORDER="0"

    text ALIGN="bottom">Metadata Definition <textarea name="metadatadefinition" value="$metadatadefinition" rows="6" cols="45" WRAP></

    textarea></td></tr><br>
    <tr><td align="RIGHT">&nbsp</td></tr>\n

    <tr><td align="RIGHT"><input type="submit" name="submit" value="Submit"></td></tr>
    </form></font></table></body></html>

    END_HTML

    }

    #Append new metadata entry to text file database
    $registry = "NewMetadataDB.txt";

    sub readparse_form
    {
    # Add to registry
    # Generate mail messages
    #&AppendRegistry(*input, $registry);

    if (&ReadParse(*IN) )
    {
    $insuranceno = $IN->param('insuranceno');
    $firstname = $IN->param('firstname');
    $lastname = $IN->param('lastname');
    $email = $IN->param('emailaddress');
    $phoneno = $IN->param('phoneno');
    $building = $IN->param('building');
    $floor = $IN->param('floor');
    $plant = $IN->param('plant');
    $project = $IN->param('project');
    $metadataname = $IN->param('metadataname');
    $metadatadefinition = $IN->param('metadatadefinition');
    }
    else
    {
    die "Unable to extract needed variables";
    }
    }


    #Open file and write input to registry file
    open (REG, ">>$registry") || die "Can't open file.";
    print REG "$insuranceno $firstname $lastname $email $phoneno $building $floor $plant $project $metadataname $metadatatype \n";
    print REG "$metadatadefinition\n";
    close (REG) || die "Can't close file.";


    #----------------------EMAIL NOTIFICATION TO KMM AND USER---------------------------------

    # Define Variables for emailing form info
    $mailprog = 'sendmail.exe';
    $recipient1 = 'blablabla@bla.com';
    $subject = "Submission of New Metadata Object to Metadata Engineering Systems";

    # Open The Mail
    open (MAIL, "|$mailprog -t") || die "Can't open $mailprog\n";
    print MAIL "To: $recipient1 \n";
    print MAIL "From: $emailaddress\n";
    print MAIL "Subject: $subject\n";

    print MAIL "The following information was submitted:\n\n";
    print MAIL "Insurance Number: $insuranceno\n";
    print MAIL "Name: $firstname $lastname'}\n";
    print MAIL "Email: $emailaddress\n";
    print MAIL "Phone Number: $phoneno\n";
    print MAIL "Building: $building\n";
    print MAIL "Floor: $floor\n";
    print MAIL "Plant: $plant\n";
    print MAIL "Project: $project\n";
    print MAIL "Metadata Name: $metadataname\n";
    print MAIL "Metadata Definition: $metadatadefinition\n\n";
    print MAIL "The information you have submitted is under review.\n\n\n";

    close (MAIL);


    These are the errors that I'm getting:
    [Tue Jun 22 13:49:25 2004] [error] [client 150.220.3.194] [Tue Jun 22 13:49:25 2004] form_validation.cgi: Name "main::metadatatype" used only once: possible typo at C:/Program Files/Apache Group/Apache2/cgi-bin/form_validation.cgi line 180., referer: http://150.220.3.194:8081/cgi-bin/form_validation.cgi
    [Tue Jun 22 13:49:25 2004] [error] [client 150.220.3.194] [Tue Jun 22 13:49:25 2004] form_validation.cgi: Name "main::in" used only once: possible typo at C:/Program Files/Apache Group/Apache2/cgi-bin/form_validation.cgi line 8., referer: http://150.220.3.194:8081/cgi-bin/form_validation.cgi
    [Tue Jun 22 13:49:25 2004] [error] [client 150.220.3.194] [Tue Jun 22 13:49:25 2004] form_validation.cgi: Name "main::IN" used only once: possible typo at C:/Program Files/Apache Group/Apache2/cgi-bin/form_validation.cgi line 157., referer: http://150.220.3.194:8081/cgi-bin/form_validation.cgi
    [Tue Jun 22 13:49:25 2004] [error] [client 150.220.3.194] [Tue Jun 22 13:49:25 2004] form_validation.cgi: Use of uninitialized value in concatenation (.) or string at C:/Program Files/Apache Group/Apache2/cgi-bin/form_validation.cgi line 180., referer: http://150.220.3.194:8081/cgi-bin/form_validation.cgi
    [Tue Jun 22 13:49:25 2004] [error] [client 150.220.3.194] [Tue Jun 22 13:49:25 2004] form_validation.cgi: Use of uninitialized value in concatenation (.) or string at C:/Program Files/Apache Group/Apache2/cgi-bin/form_validation.cgi line 180., referer: http://150.220.3.194:8081/cgi-bin/form_validation.cgi

    This "use of uninitialized value" error continues.

    Can anyone help????
    Last edited by HTML; 03-20-2007 at 12:51 PM.

  2. #2
    dancerman's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2004
    Posts
    5

    RE: CGI form input doesn't write to text file

    Did you get the problem resolved?
    L@@ks like the script does not have the server path to the text file to be able to write to it.
    Let me know as it looks like a nice form/script
    mike

  3. #3
    sudheer's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    1

    cgi form input doesnt write to text file

    hi ,
    Did u get result for the above problem .me too have a same problem .plz help me if u succeed in that problem



Tags for this Thread