Topic: I need help with WAP code

I have a wap site which obtains data from a mysql database. It doesn' work properly and i don't know why, here is the code:

<?php

// output correct HTTP content type
header( 'Content-type: text/vnd.wap.wml' );

if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
    // load vbulletin stuff
    require_once( '../vbulletin/includes/config.php3' );
   
    // validate user
    mysql_connect( $servername, $dbusername, $dbpassword );
    mysql_select_db( $dbname );
   
    $sql = <<<eos
select user_id from wap_users where username='$_POST[username]' and password='$_POST[password]' LIMIT 1
eos;

    $result = mysql_query( $sql );
   
    if ( mysql_num_rows( $result ) ) {
        $row = mysql_fetch_row( $result );
       
        $sql = <<<eos
UPDATE wap_users SET login_count=login_count+1,last_login=NOW()
eos;

        mysql_query( $sql );
       
        session_name( 'wap' );
        session_start();
        $_SESSION['wap'] = true;
       
        header( "Location: http://$_SERVER[HTTP_HOST]" . dirname( $_SERVER['PHP_SELF'] ) .

'/wap.php' );
        exit;
    }
}

?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
    <head>
        <META name="generator" CONTENT="BBEdit 6.5" />
    </head>
        <card id="servers" title="machineguard login">
    <do label="Login" TYPE="accept">
    <go HREF="#card2" METHOD="post">
        <postfield name="username" VALUE="$(username)" />
        <postfield name="password" VALUE="$(password)" />
    </go>
    </do>

Username:<BR /><INPUT TYPE="text" name="username" /><BR />
    Password:<BR /><INPUT TYPE="password" name="password" /><BR />

    </card>

</wml>

Re: I need help with WAP code

First of all, what's the problem?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: I need help with WAP code

Um not to be rude so please don't take offense of this but if he knew what the problem was would he be asking you?

Re: I need help with WAP code

He said "It doesn' work properly". He has to be able to tell us what doesn't work properly. Does it give him an error message or what?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: I need help with WAP code

I know i was just kidding and was board sry i had nothing better to do

Re: I need help with WAP code

Depending on the mobile phone on some i get a mime error on most i get a wrong data error. On my Sharp GX-20 the page will load but when i submit the form it just refreshes the page.

Re: I need help with WAP code

don't even bother using an emulator through the PC cause i'll tried and it works. But it doesn't work on real handsets

Re: I need help with WAP code

Then I guess it's a problem with the content type. Is text/vnd.wap.wml correct?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: I need help with WAP code

I think it's correct, what else could it be to work with mobile phones.

Re: I need help with WAP code

Try this at the top

header("Content-type: text/vnd.wap.wml");
echo "<xml version="1.0"?>";
echo "<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""
. " "http://www.wapforum.org/DTD/wml_1.1.xml">";

Re: I need help with WAP code

And one other thing.
IF you get php errors, the output of that is HTML, which a WML browser will not understand. The WML browser will tell you that there's an error in your wml code.

12

Re: I need help with WAP code

I now get this error.

Parse error. parse error, unexpected T_DNUMBER expecting ',' or '.' in line 4

13

Re: I need help with WAP code

do i place that code you gave me before <?php command

14 (edited by sverrir 2004-06-23 13:32)

Re: I need help with WAP code

No, just insert it below your header line >> header("Content-type: text/vnd.wap.wml");

echo '<xml version="1.0"?>';
echo '<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';

15

Re: I need help with WAP code

i did that extra code and the page loaded, but now i don't have a login option on my phone. Would it be easier to put in a 'next' button.

16 (edited by sverrir 2004-06-23 19:17)

Re: I need help with WAP code

My bad, I overlooked that you have included 

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

above <wml>.

Take

<xml version="1.0"?>

and put it above that part of the code.
If that doesn't fix things then I'm running out of ideas.

17

Re: I need help with WAP code

The page now loads but now i put that extra code in the Login option doesn't appear on my phone. Can you think of anyway for me to be able to login.

Re: I need help with WAP code

No, not at the moment sad

Re: I need help with WAP code

Maybe there is something wrong with the html causing your problem.