LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2004, 04:59 AM   #1
black_man
LQ Newbie
 
Registered: May 2003
Location: Iasi, Romania
Distribution: debian
Posts: 27

Rep: Reputation: 15
perl and wml problem


hi!

i'm trying to write a cgi script in perl to serve wap pages. it shown an input field and a button. after the user has entered the text into the field and he pressed the button, the text is written in a file.
it doesn't work because i can't get the value of the input field into a local variable.

this is the script:

#!/usr/bin/perl

use CGI::WML;
$cgi = new CGI::WML;
print $cgi->header(),$cgi->start_wml();

print $cgi->card(-id=>"card1",-title=>"Command",content=>
$cgi->p($cgi->input(-name=>"q",-value=>"")).
$cgi->p($cgi->b("Press go")).
$cgi->do(-type=>"accept",-label=>"go",-content=>
$cgi->go(-method=>"post",-href=>"#card2")));

open (FILE,'>>','data.txt');
print FILE $cgi->param('q');
close(file);

print $cgi->end_wml();

any help?
 
Old 11-03-2004, 05:13 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Say your form input field is named "myField", try

print FILE $cgi->param('myField');
 
Old 11-03-2004, 05:16 AM   #3
black_man
LQ Newbie
 
Registered: May 2003
Location: Iasi, Romania
Distribution: debian
Posts: 27

Original Poster
Rep: Reputation: 15
that is exactly what i have done. the input field is named q, and the line is
print FILE $cgi->param('q');
and it doesn't write anything in the file.
 
Old 11-03-2004, 05:23 AM   #4
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
I think you need 2 separate scripts, one for the form and another to get form POST vars. Or you can
combine them in one script but you will have to test if the form was submited to parse the vars.
 
Old 11-03-2004, 06:36 AM   #5
black_man
LQ Newbie
 
Registered: May 2003
Location: Iasi, Romania
Distribution: debian
Posts: 27

Original Poster
Rep: Reputation: 15
ok!

i made two scripts. sender.cgi reads the input and sends it to receiver.cgi. i have tested receiver.cgi by sending the parameter like this: http://192.168.0.2/receiver.cgi?q=test.
q arrives ok and its value is written to the file.

sender.cgi doesn't work. i think there is a problem in the go statement:

#!/usr/bin/perl

use CGI::WML;
$cgi = new CGI::WML;
print $cgi->header(),$cgi->start_wml();
print $cgi->card(-id=>"card1",-title=>"Command",content=>
$cgi->p($cgi->input(-name=>"q",-value=>"")).
$cgi->p($cgi->b("Apasa go")).
$cgi->do(-type=>"accept",-label=>"go",-content=>
$cgi->go(-method=>"post",-href=>"http://192.168.0.2/receiver.cgi",-postfields=>'q')));

print $cgi->end_wml();

the -postfields property isn't working (when i run the script it doesn't say 'postfield' anywhere).
how do i send the value to the other script?
 
Old 11-03-2004, 12:55 PM   #6
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Why don't you write your form in simple wml ? Do you need it is dynamic ? If yes you have to
know how to build a workable static wml form anyway.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
wml code problem black_man Programming 0 11-09-2004 11:43 AM
Binary WML the_imax Linux - Networking 1 08-28-2004 02:46 AM
wml v.2.0.9 installation glevine Linux - Software 0 06-05-2004 08:23 PM
wml and html Syncrm Programming 3 04-19-2003 06:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration