Reputation: 3
Ive built a website using CGI and Perl that has a few pages to it. I have an account registration page that saves the the users information into a data file which can be accessed by the login page to actually sign the user in. The problem Im having here is that I have all this account information saved but I'm not sure how to display it back on an html page. I know how to generate a simple html page in the .cgi script itself but thats not what I want to do. I have a .css file that I've set up which does most of the entire websites formatting for me, I want to pre-build an html form and just load the saved data up on that but I'm not quite sure how to accomplish it in CGI Perl.
As of right now I'm just generating a basic html page in the .cgi code as I mentioned before, like so
#Send the info back
print $obj->header( "text/html" ),
$obj->start_html(
-title => "Form Data",
-topmargin =>"0"
),
$obj->h1("Submitted Form Data Detail"),
$obj->p("Name: $fname $lname"),
$obj->p("Login name, password, and user name: $login, $password, $email"),
$obj->p("Gender: $gender"),
$obj->p("Streaming Services: $stream_services2"),
$obj->p("Comments: $comments"),
$obj->end_html;
Everywhere I've read online basically tried to use javascript or php which I dont want to do. Is there any way I can accomplish this in the perl code? Any suggestions or references would be greatly appreciated!
Upvotes: 0
Views: 512
Reputation: 164809
When you create the form, supply the information as defaults with -defaults
.
print $obj->textfield( -name => 'name', -default => "$fname $lname");
Alternatively, write the HTML normally and use Javascript to query a Perl program that returns the user's information as JSON. Javascript can then fill in the blanks. That is the better way to do it, it allows front-end designers to work with the HTML without needing to know Perl.
Upvotes: 1