0

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!

1
  • If I understand what you're asking, you want to put defaults into an HTML form? Like if it's a credit card payment form and you already know their zip code you can fill it in for them? Commented Mar 4, 2015 at 5:10

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.