Link to home
Start Free TrialLog in
Avatar of Sankar030999
Sankar030999

asked on

create a simple yes/no question online

I want to have a simple yes/no question on my webpage that is on unix server. Hence i have to use perl only. I just need to store the number of yes and no's. No other information like userid etc are there. Is it possible to store information in a simple txt file? Also are there any permissions that I have to set for the folder where the page and script is hosted?

How do i do this in perl?

Thanks
Avatar of Tsvetomir
Tsvetomir

Yes and it's very easy ! :)
teh clasic way to  do this is :

1. Make a html file whith the questions.
2. user submits the form with the choosen answer
3. Perl-CGI script recievies the data, opens the file and updates values;
4. print a result page back to the user or redirect him to an existent page

Yah have to set the rights :  execute (chmode 755) for the script and read/write for the data file (chmode 666)
ASKER CERTIFIED SOLUTION
Avatar of Tsvetomir
Tsvetomir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry..., better change theese two:

1.)After line 29 - ($yes, $no)=(<FH>, 0, 0);
add:

chomp($yes,$no);

(removes trailing ";" from the values if it's assigned)


2.)To prevent incrmenting "no" if no answer was selected change :

if ($answer==1) {
    ++$yes;
}else {
    ++$no;
}

# with:
if ($answer==1) {
    ++$yes;
}elsif ($answer==0){
    ++$no;
}


:))
Avatar of Sankar030999

ASKER

The solution worked perfectly...I just had to change in a few places.

Thanks
Sankar