Email: bknpk@hotmail.com Phone: +972-54-7649119
V

 

ASIC/FPGA Design and Verification Out Source Services

Interactive HTML forms using a mixture of HTML and PERL CGI scripts

  1. This short guide will discuss how to create interactive HTML forms. As an example, one may consider, the feedback form available on my site.
  2. The first step is to create an HTML starting page. This page describes the assorted options given to the user. In my example, the user is offered to enter feedback on my web site. This page calls a PERL script, which creates the form.
  3. I use form method of post action as can be seen at: Feedback Form.
  4. This PERL script prints the form fields and also generates a random code, displays it with images (non-text) and asks for the user to enter this code.
  5. The code, which this PERL script generated ,is passed to the another PERL script, via the hidden field.
  6. The last script is simple and it has to compare the codes, from user and from script, check that name and mail fields do not contain dangerous characters and write it to file.
  7. The comparison of codes is done in order to avoid script invocation of the feedback form.
  8. #!/usr/bin/perl -w
    use CGI qw(:standard);
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
    use strict;
    use Socket;

    print header;
    print start_html("Remote Host");

    my $pl_seed=time ^ $$ or time ^ ($$ + ($$ << 15));
    srand($pl_seed);
    my $Code=int(rand(10000));

    print "<FORM METHOD=\"POST\" ACTION=\"http://bknpk.dynu.com/cgi-bin/fb.pl\">n"
    print "<PRE>n";
    print "First Name: <INPUT TYPE=>
    ....
    print "< Hidden fields -->br> print "<input type=\"hidden\" name=\"vCode\" value=$Code>br> print "< hidden fields end here>br> ....
    print end_html;

    sub prt_img {
    ....

  9. A note about random number generation. The perl script uses the following command to generate the number:

    my $pl_seed=time ^ $$ or time ^ ($$ + ($$ << 15));

    Another way to generate the number, is using bash option:

    #!/bin/perl

    $rand_1=`/home/pini/Home_2/GeneralInfo/Tmp/rand.unx`;
    chomp($rand_1);
    print("$rand_1\n");

    The bash script is merely:

    #!/bin/bash

    #assign a number to RANDOM sets its seed
    #otherwise generates a a number between 0 and 32767
    echo $RANDOM

Contact me now at:

  ...


I would be happy to offer my services. Call ASAP !


Home

Download Area






Search This Site


Feedback This Site




new pages on this site