Mobile Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreMobile Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 9th, 2006, 02:44 AM
bulletz bulletz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 168 bulletz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 19 m 45 sec
Reputation Power: 5
Passing data to PHP from a .xhtml file

I'm trying to send input data to a PHP file
from an .xhtml file

.xhtml file
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" 
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Welcome to W@PSiTe</title>
</head>
<body>
<p>Welcome to W@PSiTe Mobile Service!<br/></p>
<form method="POST" action="loginwap.php">
<p>
Email :
<input type="text" name="email" />
Password :
<input type="password" name="password" />
<input type="submit" name="login_btn" value="Send Data" />
</p>
</form>
</body>
</html>


.php file
Code:
<?php  
// send wml headers 
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.dtd\">"; 
?> 
if(isset($_POST['submit'])) {
	$pwd = md5($_POST['password']);
	$email = $_POST['username'];
	$sel_q = "select * from the_table where the_email = '$email' and the_pwd='$pwd' limit 1";
	$sel_r = mysql_query ($sel_r);
	$sel_c = mysql_num_rows($sel_r);
	if ($sel_c > 0) {
		echo "<p>OK!</p>";
	} else {
		echo "<p>NOT OK!</p>";
	}
} else {
	echo "<p>Wrong password!</p>";
}


I'm using "SmartPhone Emulator 6" as my emulator.
the .xhtml is ok but when sent to the PHP file it shows
"502 error" or "Error : 502 - No gateway Reply"

Am I doing it correctly? I'm really new to WAP and all things about wireless. Any input is very much appreciated.
thanks in advance.
__________________
*** today i ask, tomorrow i help

- sandbag

Reply With Quote
  #2  
Old October 9th, 2006, 05:10 AM
jabba_29's Avatar
jabba_29 jabba_29 is online now
Back in HEL
Click here for more information.
 
Join Date: Feb 2002
Location: Finland
Posts: 8,912 jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)jabba_29 User rank is General 11st Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 4 Weeks 1 Day 12 h 41 m 36 sec
Reputation Power: 1693
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Hi there, glad you found the wap forums at last

When you are sending wap headers, the outputed xhtml has to be correct or you will get nothing back....

Personally, for xhtml I send the headers as application/vnd.wap.xhtml+xml if the phone can handle it...

Anyhow, you should make sure you have the full page in the .xhtml file, you currently don't in your snippet at least...
php Code:
Original - php Code
  1. <?php 
  2. /*
  3.   send wml headers:
  4.   try to send the same as your server is sending for .xhtml files
  5. */
  6. header("Content-type: text/vnd.wap.wml")
  7. echo '<?xml version="1.0"?>';
  8. ?>
  9. <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
  10. "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  12. <head>
  13. <title>Processing login to W@PSiTe</title>
  14. </head>
  15. <body> 
  16. <?php
  17. /* sanatize the data before using mysql */
  18.     $pwd = md5($_POST['password']);
  19.     $email = mysql_real_escape_string($_POST['username']);
  20.     $sel_q = "SELECT * FROM the_table
  21.             WHERE the_email = '$email'
  22.             AND the_pwd='$pwd' limit 1";
  23. /* make sure the query is working as expected */
  24.     $sel_r = mysql_query ($sel_r) or die('<p>'. mysql_error() .'</p>');
  25. /* this bit isn't really needed,
  26.     or at least you can do it more effectively */
  27. #
  28. #   $sel_c = mysql_num_rows($sel_r);
  29. #
  30.  
  31.     if (mysql_num_rows($sel_r) > 0) {
  32.         echo "<p>OK!</p>";
  33.     } else {
  34.         echo "<p>NOT OK!</p>";
  35.     }
  36. } else {
  37.     echo "<p>Wrong password!</p>";
  38. }
  39. /* debug, see what info is being passed */
  40. echo '<div><pre>';
  41. print_r($_POST);
  42. echo '</pre></div>';
  43. ?>
  44. </body>
  45. </html>
__________________
Cheers,

Jamie

# mdb4u | 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.



__________________

Reply With Quote
  #3  
Old October 9th, 2006, 11:20 PM
bulletz bulletz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 168 bulletz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 19 m 45 sec
Reputation Power: 5
hello:
haha, yeah...finally found the WAP forum.
thanks for the reply jabba.
i still get an error : "Reply Unknown"
here's my php code for now. (*for debugging)
.php file
Code:
<?php  
   header("Content-type: text/vnd.wap.wml, true");    
   echo '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
?> 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Processing login to W@PSiTe</title>
</head>
<body>  
<p>Welcome to W@PSiTe!</p>
<?php
echo '<div><pre>';print_r($_POST);
echo '</pre></div>';
?>
</body>
</html>


and my .xhtml file (all of it)
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" 
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>xhtml file</title>
</head>
<body>
<p>Welcome to W@PSiTe Mobile Service!<br/></p>
<form method="POST" action="loginwap.php">
<p>
Email :<br/>
<input type="text" name="email" />
Password :<br/>
<input type="password" name="password" />
<input type="submit" value="Send Data" name="login_btn" />
</p>
</form>
</body>
</html>


did I miss anything on one of the files?
thanks again.

Last edited by bulletz : October 9th, 2006 at 11:47 PM.

Reply With Quote
  #4  
Old October 10th, 2006, 03:54 AM
bulletz bulletz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 168 bulletz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 12 h 19 m 45 sec
Reputation Power: 5
I finally got it to work!
ok... now for the next step....

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreMobile Programming > Passing data to PHP from a .xhtml file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT