Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    post form page again.

    When the user input something on a perl form page and there is an error, for example, userid already exists. How do i display the error message: "UserID already exist" and at the same time display the form page again???

    Pls help......

  • #2
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Theres not really an easy quick way to do this.
    What you can do is:

    #!/usr/bin/perl


    print "Content-type: text/html\n\n";


    read(STDIN,$indata,$ENV{'CONTENT_LENGTH'});
    @indata = split(/&/,$indata);
    foreach $i (0..$#indata)
    {
    $indata[$i] =~ s/\+/ /g;
    ($key,$val) = split(/=/,$indata[$i],2);
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/%(..)/pack("c",hex($1))/ge;
    $indata{$key} .= "\0" if (defined($indata{$key}));
    $indata{$key} .= $val;


    }
    if( -e "$indata{'userid'}")
    {
    print("Error. Userid Already Exists\n");
    $error = "userid";
    }
    #THIS IS YOUR FORM
    print("
    <form action=page.cgi method=post>
    Name: <input type=text name=name size=25>\n"); if($error eq "name")print("Name incorrect\n");
    print("Userid: input type=text name=userid size=25>\n"); if($error eq "userid")print("Userid incorrect\n");

    print("Password: input type=text name=password size=10>\n"); if($error eq "password")print("Password incorrect\n");


    <input type=submit value=Signup>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •