CGI pull variables from a form

kkbenj
kkbenj used Ask the Experts™
on
It has been ages since I've done CGI Perl scripting.

My variable $UName is blank when this script is executed.  Why is not being picked up from the HTML form?
HTML:
--------------------------------------------------------------------------------------
....
</head>
<body class='d-s'>
        <form id='d-form'>
          <div class='section form'>
            <h1>Create your account</h1>
            <p>Creating an online account lets you easily update your information.</p>
            <p class='required'>
              All fields marked
              <em class='red'>*</em>
              are required
            </p>
            <h2>Create your username and password</h2>
            <fieldset>
              <ol>
                <li class='required-field' style='float: none;'>
                  <label>
                    Username
                    <em>*</em>
                  </label>
                  <input name='Wusername' type='text' />
                </li>
                <li class='required-field' style='float: none;'>
                  <label>
                    Password
                    <em>*</em>
                  </label>
                  <input id='password' name='Wpassword' type='password' />
                </li>
                <li class='required-field' style='float: none;'>
                  <label>
                    Confirm Password
                    <em>*</em>
                  </label>
                  <input id='confirmpassword' name='Wconfirmpassword' type='password' />
                </li>
              </ol>
            </fieldset>
          </div>
            <div class='submit'>
              <input class='pill-button' type='submit' url='/cgi/unamecheck.cgi' value='Start!' />
            </div>
        </form>
...
--------------------------------------------------------------------------------------
unamecheck.cgi:
...

my $UName=param('Wusername');
my $UPassword=param('Wpassword');
print "$UName - name<br>";

...
--------------------------------------------------------------------------------------

Thanks in advance for any help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
system administrator
Top Expert 2007
Commented:
Hello. Probably you didn't include 'CGI' module and initialize variable to access form fields:

use CGI;
my $q = CGI->new;
...
my $UName=$q->param('Wusername');
my $UPassword=$q->param('Wpassword');
print "$UName - name<br>";

Open in new window

Artysystem administrator
Top Expert 2007

Commented:
http://perldoc.perl.org/CGI.html read here for more information.
Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
And your form tag needs the url in the action attribute, it won't work in the submit button.

<form id='d-form' action='/cgi/unamecheck.cgi'>

Author

Commented:
Thanks to you both.  VERY rusty, as you can tell.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial