Solved

GCI validation

Posted on 1998-03-24
7
187 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
3 Use Cases for Connected Systems

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

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now