APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

© October 2002 Tony Lawrence

Simple User Request Forms

October 2002

We often have the need for simple forms that request certain actions like adding a new user, etc. A simple perl script lets us do this with a web form that then emails the results.

The example here can be modified to meet your needs. The things that you need to know are noted in comments.

use CGI qw(:standard);

if (defined $posting) {
# this section only happens when the form is submitted
# your email may not be /bin/mail 
  open MAIL, "|/bin/mail -s \"IT User Request\" itstaff\@yourcompany.com";
  $requestor="|/bin/mail -s \"Your IT User Request\" $email";
  open MAILO, $requestor;
  print MAIL "Subject: IT user request\n\n";
  print MAILO "$Subject: Your IT user request\n\n";
  print MAILO "\nConfirming your request:\n\n";
# print the results to mail
foreach $i (param) {
# skip the posting flag
  next if $i =~ /posting/;
  foreach $j (param($i) ) {
# strip off the prefix
    $v =~ s/^.._//;
    print MAIL "$v = $j\n";
    print MAILO "$v = $j\n";
print header, <<EOF;
<html><head><title> IT User Request</title></head><body>
<h2>Accepted, thank you</h2>
<form action="/cgi-bin/simpleform.pl" method=POST>
foreach $i (param) {
  next if $i =~ /posting/;
  foreach $j (param($i) ) {
    $v =~ s/^.._//;
    print "<br>$v = $j\n";
print <<EOF;
<p><input type=submit name=accept value="OK">
exit 0;

# this is what happens when the script is first called
print  header, <<EOF;
<html><head><title> IT User Request</title></head><body>
<h2>IT User Request</h2>
<form action="/cgi-bin/simpleform.pl" method=POST>
# you can modify any of these.  The first 3 characters of 
# the variable names let us easily control order if we need to
<p>Requested by: <input type=text name=aa_requestor size=20>
<p>Your email: <input type=text name=ab_email size=20>
<p>Your telephone: <input type=text name=ab_phone size=20>
<p><input name=ac_type type=radio value="New User">New User
<input name=ac_type type=radio value="Terminate User">Terminated User
<p>User's Login <input type=text name=ad_user_login size=4>
<p>User's name: <input type=text name=ae_username size=20>
<p>(if new) Desired password: <input type=text name=af_desired_password size=20>
<p>Systems to add or terminate:
<p> <input name=ag_systems type=checkbox value="Network">Network
<p> <input name=ag_systems type=checkbox value="Unix">Unix
<p> <input name=ag_systems type=checkbox value="File and Print">File and Print
<p> <input name=ag_systems type=checkbox value="E-Mail">E-Mail
<p> <input name=ag_systems type=checkbox value="E-Fax">E-Fax
<p> <input name=ag_systems type=checkbox value="Telephone/Voice Mail">Telephone/Voice Mail
<p><textarea name=zz_notes rows=10 cols=80 wrap=physical></textarea>
<p><input type=submit name=posting>

Got something to add? Send me email.

(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> Simple User Request Forms

Inexpensive and informative Apple related e-books:

Take Control of Parallels Desktop 12

Take Control of Preview

iOS 10: A Take Control Crash Course

Take Control of OS X Server

Sierra: A Take Control Crash Course

More Articles by © Tony Lawrence

Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Printer Friendly Version

Dead trees and polluting ink. I'll be happy to see them go. (Tony Lawrence)

Linux posts

Troubleshooting posts

This post tagged:






Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode