Solved

GCI validation

Posted on 1998-03-24
7
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

751 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