My code from below is suppose to take user input and submit it to a database. Everything works fine except of course for the data being stored in their respective variables. Whenever I attempt to do this I have a custom error_message returned for each field. I know its not the $error_message problem or how I submit the data yet I was thinking it was one of the three snippets below:
&print_page_start;
if($query->param('submitted')) {
$error_message = "";
&validate_form;
if($error_message eq "") {
&submit_form_values;
}
else {
print "<form><tr><td colspan=2 bgcolor=#FFFFFF><font face=Arial
+size=2 color=#FF0000>
<br><b>\n" . $error_message . "</b></td></tr></form>\n";
}
}
else {
&set_initial_values;
&print_form;
}
&print_page_end;
or
sub set_initial_values {
$firstname = $query->param('firstname');
$lastname = $query->param('lastname');
$email = $query->param('email');
$phone = $query->param('phone');
$dob = $query->param('dob');
$workstation = $query->param('workstation');
$username = $query->param('username');
$password = $query->param('password');
$passagain = $query->param('passagain');
}
or
# the important part of submit form
sub print_form {
print "<form action=register.cgi method=post>\n";
print "<input type=\"hidden\" name=\"submitted\" value=\"yes\" />\
+n";
print "<tr><td colspan=2 bgcolor=#FFFFFF><font face=Arial size=2 c
+olor=#000000>
<br>First Name</font></td><td bgcolor=#FFFFFF><input type=\"text\"
+ name=\"$firstname\" size=25 maxlength=20 />
</td></tr> \n";
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.