Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 2nd, 2001, 01:09 AM
renonet renonet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 renonet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

it should be able to add the if condition to validate the user inputs when developing cgi using html::template module, bye why my cgi script that uses html::template only responses the last if statement instead of checking from the 1st if statement so on. for example, this is a piece of code from my script,

#!/usr/bin/perl

use HTML::Template;
print "Content-type:text/html\n\n";
my $template = HTML::Template->new(filename => 'test.tmpl');
..

if (!$tempale->param(username => '') or !$template->param(password => '')){
print "Invalid registration";
}

if (!$template->param(username => ''){
print "Invalid username";
}

print $template->output;

The problem is why It always returns the second if statement even I already put words in the username field.
I was trying to put a piece of information on the sign-in form and call the static html, rather than
re-print all the static layout. Is it the correct way to do?

Reply With Quote
  #2  
Old April 2nd, 2001, 01:08 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
I'm not sure if this is the right answer, but don't you have to pass the CGI.pm query to HTML::Template inorder to be able to access form infomation using:

$template->param(username => '');

Why not try using

$q = new CGI;

if(!$q->param(username)) { print "invalid username" }

hope that helps

Reply With Quote
  #3  
Old April 2nd, 2001, 08:50 PM
renonet renonet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 renonet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for your reply unobserved.
actually if you put <TMPL_VAR NAME = 'param'> together with INPUT TAG like this:
<INPUT NAME=param TYPE=TEXT VALUE="<TMPL_VAR NAME="username">"> then you will be able to manipulate the parameter in your CGI script,
if (!$template->param(username => ''){
....
}
my CGI can return the parameter to HTML using this method, but the problem is when I add another IF statement, the logic always goes to the last IF statement without analyzing the previous ones. It's weird :-)

Reply With Quote
  #4  
Old April 3rd, 2001, 08:28 AM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
in that case .. it .. correct me i'f i'm wrong, but

if(!$template->param(username => '') <--

does that statement not mean : if not user name has a value, basically do this if username has any value.

what about

Code:
if($template->param(username => '') || $template->param(password => '')) {print 'invalid registration'; }

elsif($template->param(username => '')) { print "unknown user"; }


notice no !'s.
just my suggestion

Reply With Quote
  #5  
Old April 3rd, 2001, 11:44 AM
renonet renonet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 0 renonet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb

hi observed,
I know I shouldn't put the '!' in front of $template. I had tried to take out the '!', but nothing came out. By adding '!' at least I got something, but unfortunately is still not that I want. Anyway, thanks for your suggestion.

There's something to share with you, according to Sam Tregar HTML:Template can't do input processing, it only handles ouput.

Regards,

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > if statement using HTML::TEMPLATE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT