cobra has asked for the wisdom of the Perl Monks concerning the following question:

This one's for all you people who have tried a bit of WAP programming. I'm trying to create a login script that allows registered users to log in and displays a page with hyperlinks to other cards within the deck. The card I'm using to test this is the viewroutes card and the problem is that when I select that hyperlink, it takes me to the card which displays the wrong username message.
#!/usr/local/bin/perl -w $ENV{ORACLE_HOME} = '/opt/ORACLErdbms/V8.0.6.0'; use DBI; use CGI; $query = new CGI; $username = $query->param('username'); $password = $query->param('password'); $dbh = DBI->connect('DBI:Oracle:eimora','cs72dc','cs72dc') || die "Cannot connect: $DBI::errstr"; $verify = "SELECT user_name,user_pass FROM users WHERE user_name = \'$ +username\'"; $mine = $dbh->prepare($verify) || die "Cannot prepare statement: DBI::errstr"; $mine->execute || die "Cannot execute statement: DBI::errstr"; ($test_username,$test_password) = $mine->fetchrow_array(); $mine->finish; if (($test_username eq $username) && ($test_username ne $null)) { if (($test_password eq $password) && ($test_password ne $null)) { $statement = "SELECT route FROM history WHERE username=\'$user +name\'"; $mine = $dbh->prepare($statement) || die "Cannot prepare statement: DBI::errstr"; $mine->execute || die "Cannot execute statement: DBI::errstr"; $route = $mine->fetchrow_array(); $mine->finish; print<<"EOF"; Content-type: text/vnd.wap.wml <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml" > <wml> <card id="menu" title="MRP"> <p>Welcome $username </p> <p> <a href="#viewroute"> view routes </a> </p> </card> <card id="viewroute" title="MRP"> <p>Saved Routes </p> <p> <a href="$route"> $route </a> </p> </card> </wml> EOF } else { print<<"EOF"; Content-type: text/vnd.wap.wml <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml" > <wml> <card id="WrongPassword" title="MRP"> <p>Wrong Password </p> <p align="left"> <a href="index.wml"> Try again </a> </p> </card> </wml> EOF } } else { print <<"EOF"; Content-type: text/vnd.wap.wml <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml" > <wml> <card id="WrongUsername" title="MRP"> <p>Wrong Username </p> <p align="left"> <a href="index.wml"> Try again </a> </p> </card> </wml> EOF } $dbh->disconnect;
Pleeease help me!

Replies are listed 'Best First'.
Re: Fiddling with WAP
by shotgunefx (Parson) on May 15, 2001 at 23:02 UTC
    It appears to me that you are not passing the username and pass along to the subsequent links.

    Once you log in and click the link, you are not passing along the $username and $pass to the next call which brings you back to the login screen, which I believe because you have no $username and $pass, gives you the error.

    (I'm pretty sure that when you do the deck transition, it still calling the script again which means the username ans pass are long gone)

    I haven't done too much with WML but you should check out the following CPAN module, CGI::WML, this subclasses CGI.pm to generate WML output.

    Hope this helps.
Re: Fiddling with WAP
by ckohl1 (Hermit) on May 15, 2001 at 22:46 UTC
    I can tell you that when I hard code the username and password values at the beginning of your code (and build tables to emulate your environment), I have no problem reaching the menu portion of your code. Have you tried to perform a debug print of the values that you are getting from the phone/WAP emulator for the username and password pair?


    Chris
    'You can't get there from here.'