View Full Version : Tables and Forms
Ok. I am working on a perl script in which I have to print a form on a web page. I am trying to also make it look nice, however, I cannot embed tables or it completely messes up. Here is part of it:
print "Name: < input type=text name=\"name\" value=\"$FORM{'name'}\" size=45>\n";
I am trying to put this in a table like this (The < table> tags are in another line of the code.
print "< table width=\"100%\">< tr>< td>< strong>Name: < /strong>< /td>< td>< input type=text name=\"name\" value=\"$FORM{'name'}\" size=45>< br>< /td>< /tr>\n";
The value=\"$FORM{'name'}\" messes up with the tables, and I really don't know why.
YUPAPA
03-26-2003, 11:46 PM
Try this:
print qq(
<TABLE WIDTH="100%">
<TR>
<TD><STRONG>Name:</STRONG></TD>
<TD><INPUT TYPE="TEXT" NAME="name" VALUE="$FORM{'name'}" SIZE="45"></TD>
</TR>
</TABLE>
);
Cool Thank you very much :)
But what exactly is the difference between print and printqq? and will they work side by side like:
print "<table>/n";
print "<tr>/n";
print "<td>/n";
print "Text/n";
print "</td>/n";
print "</tr>/n";
print "</table>/n";
Thanks again
Also, can the print qq work alongside print like what I had; can I have something like this?
print qq(<html><head><title>Test Page</title></head><body>\n);
print "<table>/n";
print "<tr>/n";
print "<td>/n";
print "Text/n";
print "</td>/n";
print "</tr>/n";
print "</table>/n";
print qq(</body></html>\n);
Thanks
YUPAPA
03-27-2003, 02:22 AM
Yes :p
Ok Thanks... Now tell me what's wrong here.
elsif ($error eq 'field_size') {
print qq(<html><head><body>\n);
print qq(<center><h1>ERROR: Field too Long</h1></center>\n);
print qq(One of the form fields in the message submission was too long. The following are the limits on the size of each field (in characters):<p>\n);
print qq(<ul><li>Name: $max_len{'name'},</li>\n);
print qq(<li>E-Mail: $max_len{'email'}</li>\n);
print qq(<li>Subject: $max_len{'subject'}</li>\n);
print qq(<li>Body: $max_len{'body'}</li>\n);
print qq(<li>URL: $max_len{'url')</li>\n);
print qq(<li>URL Title: $max_len{'url_title'}</li>\n);
print qq(<li>Image URL: $max_len{'img'}</li></ul>\n);
print qq(Please modify the form data and resubmit.<p><hr size=7 width=75%><p>\n);
&rest_of_form;
print qq(body></html>\n";
}
Here is the debugger error:
Software error:
syntax error at wwwboard.pl line 669, near "print"
BEGIN not safe after errors--compilation aborted at wwwboard.pl line 668.
YUPAPA
03-27-2003, 05:04 PM
The part that I bolded.
Originally posted by Saj
Ok Thanks... Now tell me what's wrong here.
elsif ($error eq 'field_size') {
print qq(<html><head><body>\n);
print qq(<center><h1>ERROR: Field too Long</h1></center>\n);
print qq(One of the form fields in the message submission was too long. The following are the limits on the size of each field (in characters):<p>\n);
print qq(<ul><li>Name: $max_len{'name'},</li>\n);
print qq(<li>E-Mail: $max_len{'email'}</li>\n);
print qq(<li>Subject: $max_len{'subject'}</li>\n);
print qq(<li>Body: $max_len{'body'}</li>\n);
print qq(<li>URL: $max_len{'url')</li>\n);
print qq(<li>URL Title: $max_len{'url_title'}</li>\n);
print qq(<li>Image URL: $max_len{'img'}</li></ul>\n);
print qq(Please modify the form data and resubmit.<p><hr size=7 width=75%><p>\n);
&rest_of_form;
print qq(body></html>\n";
}
Here is the debugger error:
Software error:
syntax error at wwwboard.pl line 669, near "print"
BEGIN not safe after errors--compilation aborted at wwwboard.pl line 668.
Err never mind, that was stupid of me. There must be something else in there thats incorrect because I deleted some tags before that, must have deleted the openening of </body> as well. Can you see anything else wrong with that?
YUPAPA
03-27-2003, 08:40 PM
Why not just do
elsif ($error eq 'field_size') {
print qq(
<html><head><body>
<center><h1>ERROR: Field too Long</h1></center>
One of the form fields in the message submission was too long. The following are the limits on the size of each field (in characters):<p>
<ul><li>Name: $max_len{'name'},</li>
<li>E-Mail: $max_len{'email'}</li>
<li>Subject: $max_len{'subject'}</li>
<li>Body: $max_len{'body'}</li>
<li>URL: $max_len{'url'}</li>
<li>URL Title: $max_len{'url_title'}</li>
<li>Image URL: $max_len{'img'}</li></ul>
Please modify the form data and resubmit.<p><hr size=7 width=75%><p>
);
&rest_of_form;
print qq(
<body></html>
);
}
Same Error:
syntax error at wwwboard.pl line 662, near "li>"
BEGIN not safe after errors--compilation aborted at wwwboard.pl line 668.
I'll add the line numbers...forgot to do it last time:
660: elsif ($error eq 'field_size') {
661: print qq(<html><head><body>
662: <center><h1>ERROR: Field too Long</h1></center>
663: One of the form fields in the message submission was too long. The following are the limits on the size of each field (in characters):<p>
664: <ul><li>Name: $max_len{'name'},</li>
665: <li>E-Mail: $max_len{'email'}</li>
666: <li>Subject: $max_len{'subject'}</li>
667: <li>Body: $max_len{'body'}</li>
668: <li>URL: $max_len{'url')</li>
669: <li>URL Title: $max_len{'url_title'}</li>
670: <li>Image URL: $max_len{'img'}</li></ul>
671: Please modify the form data and resubmit.<p><hr size=7 width=75%><p>);
672: &rest_of_form;
673: print qq(</body></html>\n);
674: }
YUPAPA
03-27-2003, 09:03 PM
It is
668: <li>URL: $max_len{'url'}</li>
not
668: <li>URL: $max_len{'url')</li>
Thank you very much...these small things are so hard to see, its nice having someone else to look at it who hasn't stared it for ages.
Thanks again.
j_mmontero
03-28-2003, 07:16 PM
Another way could be
$table = qq~ < input type=text name="name" value="$FORM{'name'}" size=45>~;
then you can replace it with
$screen =~ s/TABLE/$table/gs;
Hmm yea that's a good idea. Thanks :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.