|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
WML variables problem
Hi there, i've had a good look through these forums and have found nothing that helped, so i thought it was time to post the question myself.
According to W3 (http://www.w3schools.com/wap/wml_variables.asp) To gain access to a variable passed by a form you need to use lets say: $(name) This proves a bit of a problem for me seeing as i'm wanting to use those variables to login and insert something into my database. In order for me to gain access to those vars, i've tried: $newvar = '$(name)'; Now the above works when you echo or print something, but when you want to pass the variable over to to an SQL query it seems to use the value as: $(name) Is there anyone out there who can suggest a better way for me to collect the variables being passed when a form is filled out on a WAP site? Thanks for any help. David
__________________
----- Do you fear the obsolescence of the metanarrative apparatus of legitimation?
|
|
#2
|
|||
|
|||
|
which tools did you use to connect to the database
|
|
#3
|
||||
|
||||
|
Well i'm using PHP for the output of WML headers to falsify a .wml page.
So i guess the answer is PHP (mysql_connect and such) David |
|
#4
|
|||
|
|||
|
This works for me (I've just tried it!) :O)
<?php header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> <wml> <card id="main" title="Log ind"> <p> Username: <br /> <input title="user" name="username" /> Password: <br /><input title="pass" name="password" type="password" /> <anchor> Login <go href="check.wml" method="post"> <postfield name="username" value="$(username)"/> <postfield name="password" value="$(password)"/> </go> </anchor> </p> </card> </wml> And check.wml: <?php header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> <wml> <card id="varcheck" title="VARS"> <p> <?php if(isset($_POST["username"])) { echo $_POST["username"]; $name = 1; } echo"<br/>"; if(isset($_POST["password"])) { echo $_POST["password"]; $pass = 1; } echo"<br/>"; if(isset($name) && isset($pass)) { $db = @mysql_connect("localhost", "stefnik", "****da") or die ("Kunne desværre ikke forbinde til databasen!"); mysql_select_db("wapworld", $db) or die ("Kunne desværre ikke forbinde valgte database!"); $dumping = mysql_query("INSERT INTO `testing` (`name`, `password`) VALUES ('$_POST[username]', md5('$_POST[password]'))") or die (mysql_error()); if($dumping) { echo"Succes!"; } } ?> </p> </card> </wml> And dump for DB: CREATE TABLE testing ( id tinyint(3) NOT NULL auto_increment, name varchar(16) NOT NULL default '', password varchar(32) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; |
|
#5
|
||||
|
||||
|
I must thank you very much
![]() That's what i need to know, how to get the WML variables registered as PHP $_POST variables. This works a treat now. Thanks. David |
|
#6
|
|||
|
|||
|
HI there,
I am using xampp server and havign hard time interpreting the code!!! when i eliminate the echo part : xml version....it is interpreted but no variables passing!!! any idea?? what server are u using thanks Niha |
|
#7
|
||||
|
||||
|
Hi Niha,
Welcome to DS. Oh wait.... You waited 4 years to post your first comment ![]() Please don't bump old threads ![]() Can you explain exactly what your problem is and post relevant code snippets?
__________________
Cheers, Jamie # mdb4u | The mobile movie database | Please help to test and promote # skiFFie | Home of the 'accessibility module' for Drupal # Jamie Burns [me] Accessibility Module [drupal] # guidelines | search | wap resources | not getting help | fold to cure __________________ Let the might of your compassion arise to bring a quick end to the flowing stream of the blood and tears ..... Please hear my anguished words of truth. ![]() __________________ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Mobile Programming > WML variables problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|