Feb 16, 2015, 1:20 PM
Post #2 of 2
Re: [hotguy04] viewprofile.cgi
[In reply to]
There are major improvements you could make to your code but for now I am just going to answer your query of "I want to display my form data on same browser page after submitting". You have fetched form data via CGI's param, i.e. username, password and postback, and assigned them to the variables $usrn, $pass, $postback respectively. You can fetch all form data in a similar manner and then its up to you how you use the variables. If for example you want to re-populate the username field with the current username value upon failure, place $usrn anywhere in your double quoted print statement and it will interpolate. It is also a good idea to check values from param are defined ( to prevent "use of uninitialized value in concatenation" warning IF you were using warnings ) and html escape them before printing ( to prevent accidental html markup breakage ).
$usrn = param("username");
$usrn = '' unless defined $usrn;
$usrn = escapeHTML( $usrn );
print "Username: <input type='text' name='username' value='$usrn'>"
(This post was edited by Zhris on Feb 16, 2015, 1:24 PM)