Here is my php code with the beginning and end of WML for your references (this is from code I’ve written previously):
/* Connections */ <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $host=2; switch($host){ case 1: { $hostname_wap = "localhost"; $database_wap = "db_wap"; $username_wap = "root"; $password_wap = "michael"; } break; case 2: { $hostname_wap = "localhost:3360"; $database_wap = "db_wap"; $username_wap = "deadxtxt"; $password_wap = "MsDx*?"; } break; default: break; } $wap = mysql_pconnect($hostname_wap, $username_wap, $password_wap) or trigger_error(mysql_error(),E_USER_ERROR); ?> /*WML + PHP */ <?php $getaccept = $HTTP_SERVER_VARS['HTTP_ACCEPT']; $getbrowser = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; if(checkagent($getbrowser)) { header("location: http://www.textntouch.com/awap"); exit(); } else if(!strrpos($getaccept,"vnd.wap.xhtml")) { echo "this page is not browsable for desktop browsers"; exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" target="_blank" target="_new">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" target="_blank" target="_new">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>wap @ textntouch</title> </head> <body> <p align="center"> <form action="chkacc/verify.php" method="post"> <img src="images/wap.jpg" alt="textntouch logo" height="20" width="100"/> <br/> <small>welcome administrator</small><br/> <br/> Enter your username: <br/> <input type="text" name="usr" value="" size="10"/> <br/> Enter your password: <br/> <input name="pd" type="password" value="" size="10"/> <br/> Enter your security code: <br/> <input name="sc" type="password" value="" size="10"/> <br/> <input type="submit" value="login"/> <br/> <br/> <small> 2005 by textntouch.com</small> <br/> </form> </body> </html> <?php unset($_SESSION['sessareference']); unset($_SESSION['sessauser']); unset($_SESSION['sessauserlevel']); function checkagent($strval){ $blnvalid = false; if(preg_match("/bNokiab/i",$strval)) { $blnvalid = true; } return $blnvalid; } ?> /*others*/ <? session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" target="_blank" target="_new">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" target="_blank" target="_new">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Verify</title> </head> <body> <p align="center"> <br/> <?php if($HTTP_SERVER_VARS['REQUEST_METHOD']=="POST" && isset($HTTP_POST_VARS['usr']) && isset($HTTP_POST_VARS['pd']) && isset($HTTP_POST_VARS['sc'])) { require_once("../Connections/admin.php"); $footer="<br/> <br/> <small> 2005 by textntouch.com</small> <br/> </body> </html>"; $strlogname=(get_magic_quotes_gpc()) ? $HTTP_POST_VARS['usr'] : addslashes($HTTP_POST_VARS['usr']); $strpwd=(get_magic_quotes_gpc()) ? $HTTP_POST_VARS['pd'] : addslashes($HTTP_POST_VARS['pd']); $strscd=(get_magic_quotes_gpc()) ? $HTTP_POST_VARS['sc'] : addslashes($HTTP_POST_VARS['sc']); $tmpsessdir=session_save_path(); $strquery=sprintf("SELECT * FROM lctbladmingroup WHERE STRCMP(BINARY(UserName),'%s')=0 AND STRCMP(BINARY(Password),'%s')=0 AND STRCMP(BINARY(SecurityCode),'%s')=0;",$strlogname,$strpwd,$strscd); $rsadmin = mysql_db_query($database_admin,$strquery) or die(mysql_error()); $rnumadmin = mysql_num_rows($rsadmin); if(!$rnumadmin){ echo 'login failed, access denied'; echo '<br/>'; echo '<a href="../index.php">click here</a>'; echo $footer; exit(); } mysql_free_result($rsadmin); $strquery=sprintf("SELECT * FROM lctbladmingroup WHERE STRCMP(BINARY(UserName),'%s')=0 AND STRCMP(BINARY(Password),'%s')=0 AND STRCMP(BINARY(SecurityCode),'%s')=0 AND Status=0;",$strlogname,$strpwd,$strscd); $rsadmin = mysql_db_query($database_admin,$strquery) or die(mysql_error()); $rnumadmin = mysql_num_rows($rsadmin); if(!$rnumadmin) { $strquery1=sprintf("SELECT * FROM lctbladmingroup WHERE STRCMP(BINARY(UserName),'%s')=0 AND STRCMP(BINARY(Password),'%s')=0 AND STRCMP(BINARY(SecurityCode),'%s')=0 AND Status=1;",$strlogname,$strpwd,$strscd); $rsadmin=mysql_db_query($database_admin,$strquery1) or die(mysql_error()); $rstbadmin=mysql_fetch_array($rsadmin,MYSQL_NUM); $strgetsessid="sess_".$rstbadmin[9]; if (file_exists($tmpsessdir."/".$strgetsessid)) { $strquery1=sprintf("UPDATE lctbladmingroup SET Status=%d, SessionID='%s' WHERE STRCMP(BINARY(UserName),'%s')=0 AND STRCMP(BINARY(Password),'%s')=0 AND STRCMP(BINARY(SecurityCode),'%s')=0 AND Status=1;",0,"",$strlogname,$strpwd,$strscd); $cpath = $tmpsessdir."/".$strgetsessid; unlink($cpath); echo '<small>login failed</small>'; echo '<br/>'; echo '<small>Multiple login is not allowed!<br/>Note: Quit your wap browser <br/> And <br/> clear the cache</small><br/><br/>'; echo $footer; exit(); } } else { $rstbadmin = mysql_fetch_array($rsadmin,MYSQL_NUM); } $strgetref=$rstbadmin[0]; $strgetuser=$rstbadmin[1]; $struserlevel=$rstbadmin[8]; unset($_SESSION['sessretry']); unset($_SESSION['sesspwd']); unset($_SESSION['sessscd']); $_SESSION['sessareference'] = $strgetref; $_SESSION['sessauser'] = $strgetuser; $_SESSION['sessauserlevel'] = $struserlevel; $getservertime = date("Y-m-d h:m:s"); $strquery=sprintf("UPDATE lctbladmingroup SET ServerLastSignIn='%s', Status=%d, SessionID='%s' WHERE ReferenceNum='%s';",$getservertime,1,session_id(),$strgetref); mysql_db_query($database_admin,$strquery) or die(mysql_error()); mysql_free_result($rsadmin); mysql_close($admin); echo '<small>login success</small>'; echo '<br/>'; echo '<a href="../main.php">click here</a>'; echo '<br/>'; echo 'textntouch wap-enabled<br/>'; echo '<br/>'; echo $footer; exit(); } else { echo 'login failed, access denied'; echo '<br/>'; echo '<a href="../index.php">click here</a>'; echo $footer; exit(); } ?>
If you are interested in the full source code of my work, kindly email me at [email protected]. Thanks!