Solved

GCI validation

Posted on 1998-03-24
7
189 Views
Last Modified: 2013-12-25
I am processing forms using CGI for Perl using UNIX ,
1. how can I validate a data entered in the form for a valid data?

2. How can I check if a selection has been made
e.g

Sex       :<select size="1" name"sex">
<option selected>Please select sex </option>
<option>Male </option>
<option>Female </option>
</select></p>

How can I check if an option is been selected when submitting the form ?

When the user enter the address
eg.

222 Highland Road
Westminster
WE12

How can I store the address in my text files as it appear
above and not in one single line ?
0
Comment
Question by:aswad012698
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1832195
You should first tell which language on what OS you are working with.

You should also note that most of the form validation can be done on the client side, with Javascript; this has the advantage of lowering a lot the server load, and the disadvantage that Javascript does not work reliably on different browser types and versions.
0
 

Author Comment

by:aswad012698
ID: 1832196
Edited text of question
0
 

Author Comment

by:aswad012698
ID: 1832197
Thanks Julio,

I am using CGI for Perl and the operating systems is UNIX.

0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 1

Accepted Solution

by:
thufir earned 20 total points
ID: 1832198
let's start with how to put the address into multiple lines instead of one....
--------------------
to start with...FILENAME is the text file you're writing to...the other variables ($variable name) I'm using in this example are:
222 Highland Road --- $street
Westminster       --- $city
WE12              --- $zip_or_city_code
----------------------------------------------------------------
open(FILENAME)
print(FILENAME) "$first_address_variable\n"
print(FILENAME) "$city\n"
print(FILENAME) "$zip_or_city_code\n"
close(FILENAME)
-----------------------------------------------------------

Back to the first question, how to tell if a variable is used, there are two ways.  The way I usually use is to check if it's used, and show an error if it's not entered.  If you get confused let me know and I'll explain a bit more
-----
print "<ul>";
foreach $var (keys (%registration-data))
   {
   if (length($registration-data{"$var"})==0)
      {
      print "<li>Your <em> $var </em> will be used to help confirm your order. Please fill in the <em> $var </em> field";
      }
   }
print "</ul>"
0
 

Author Comment

by:aswad012698
ID: 1832199
Thanks thufir's for answering my question ..I have managed to sort out the address problem...but I am confused about checking if an option is selected :

Sex  :<select  name"sex">
    <option selected>Please select sex </option>
    <option>Male </option>
    <option>Female </option>
    </select></p>

how can check in the CGI if the user has selected one of the options ?

Many Thanks

0
 

Author Comment

by:aswad012698
ID: 1832200
Thanks thufir's for answering my question ..I have managed to sort out the address problem...but I am confused about checking if an option is selected :

Sex  :<select  name"sex">
    <option selected>Please select sex </option>
    <option>Male </option>
    <option>Female </option>
    </select></p>

how can check in the CGI if the user has selected one of the options ?

Many Thanks

0
 
LVL 1

Expert Comment

by:thufir
ID: 1832201
It's basically like this, I hope it helps...if not, let me know and I'll try again:

if (defined(sex))
  {
  whatever functions you need if selected
  }
else
  {
  whatever functions you need if not selected
  }
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question