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>