By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,405 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,405 IT Pros & Developers. It's quick & easy.

WML PHP login page

P: n/a
XP
I am having problems with the blow page. I have a login page where I
enter the userid and password. This then connects to this page. If I
enter the userid and password correctly, it prints successfully logged
into system. If I enter the wrong information all I get is an erro page
HTTP status 502 etc.

Can anyone help?

<?php

Header("Content-type: text/vnd.wap.wml");
Header("Cache-Control: no-cache, must-revalidate");
Header("Pragma: no-cache");
echo ("<?xml version='1.0'?>");
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="result" title="Test password login">
<p>
<?php
// connect to mysql database
$dab = mysql_pconnect("localhost", "root");
$db = mysql_select_db("login");

$query = "SELECT user, pass FROM login WHERE user='$userid' AND
pass='$password'";
$result = @mysql_query($query);
if(!$result){
$err=mysql_error();
print$err;
exit();
}
if(mysql_affected_rows()==0){
print"no such login in the system";
exit();
}
else{
print "successfully logged into system";
}
print "<b> output....</b> <br/>";
print "$password";



?>
</p>
</card>
</wml>

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
XP wrote:
I am having problems with the blow page. I have a login page where I
enter the userid and password. This then connects to this page. If I
enter the userid and password correctly, it prints successfully logged
into system. If I enter the wrong information all I get is an erro page
HTTP status 502 etc. [snip] <wml>
<card id="result" title="Test password login"> [snip] if(mysql_affected_rows()==0){
print"no such login in the system";
exit(); [snip] </card>
</wml>


The xml will be malformed if you exit before closing nodes.

/Bent
Jul 17 '05 #2

P: n/a
XP
Thanks. That seems to work now.

How do I add things into the if or else. For example after printing
successfully logged into system, how do I make it go to specific page?
When I add to the else statement, I get an error. What format do I need
to enter here?

Jul 17 '05 #3

P: n/a
XP wrote:
Thanks. That seems to work now.

How do I add things into the if or else. For example after printing
successfully logged into system, how do I make it go to specific page?
The principles are the as for ordinary web-pages. For most part, you
wont waste time by trying out methods in a ordinary browser. Best would
be a wap-emulator, as you are more likely to get some sensible
information in case of errors.

How you would do things like login pages, would depend on what kind of
limitations a wap-device would have. It is not something I am familiar
with, so I cannot really help you there. But I would look into if a
wap-device would behave properly if using php-sessions, cookies, and if
it would understand a location header. That will make things easier.

When I add to the else statement, I get an error. What format do I need
to enter here?


You dont actually need to have you control structure where the output
should be. You can store things in a variable and print it out later.

if ($user_is_valid) {
$content_of_card1 = '<a href="...">proceed</a>';
} else {
$content_of_card1 = 'access denied';
}
....
<card ...
<?php echo $content_of_card1; ?>
There seems to be plenty of info on wap on the net (google for more):
http://www.zend.com/zend/tut/wap.php
http://www.w3schools.com/wap/
/Bent
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.