Hello again wise ones. I am hoping someone can help me do the following. using the html and cgi code below this is what I would like to do. Have the cgi test the form as it does and if it finds a problem return the user back to the html form but fill the fields with whatever data they already entered and display an error message at the top. I can of course print the error and tell them to click back but would rather save them the clicks. I tried a redirect and passing the args using $key=$value but that didn't work. I know this is prob something simple but I am stumped. Thanks in advance for any help.
<html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=windows-12 +52"> <title>Name</title> </head> <body> <form name=form method="POST" action="http://localhost/vfsscripts/junk +.cgi"> <blockquote> <blockquote> <blockquote> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb +sp;&nbsp;&nbsp; Name&nbsp; <input type="text" name="Name" size="20"></ +p> <blockquote> <blockquote> <p>Email&nbsp;&nbsp;&nbsp; <input type="text" name="Email" size="20"></p> <p><font face="Verdana" size="1"> <input type="submit" value="Submit" tabindex="37"></font></p> <p>&nbsp;</p> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> </form> </body> </html>
#!c:/Perl/bin/Perl.exe use CGI; print "Content-type: text/html\n\n"; $query = new CGI; &testform(); sub testform{ $Name = $query->param("Name"); $Email = $query->param("Email"); if(($Name !~ /\w/) || ($Email !~ /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0 +-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){ #### SEND BACK TO HTML FOR AND FILL IN WITH DATA ALREADY ENTER +ED #### } else { print "Name => $Name<br>"; print "Email => $Email<br>"; } }

In reply to have cgi send data back to form on error by boat73

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.