Solved

GCI validation

Posted on 1998-03-24
7
185 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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

20 Experts available now in Live!

Get 1:1 Help Now