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

WML PHP Login pages

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>

Reply

Bent Stigsen May 4, 4:17 pm show options
Newsgroups: comp.lang.php
From: Bent Stigsen <n...@thevoid.dk> - Find messages by this author
Date: Wed, 04 May 2005 17:17:34 +0200
Local: Wed,May 4 2005 4:17 pm
Subject: Re: WML PHP login page
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

- Hide quoted text -
- Show quoted text -
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

Reply

XP May 4, 5:09 pm show options
Newsgroups: comp.lang.php
From: "XP" <auj...@dsl.pipex.com> - Find messages by this author
Date: 4 May 2005 09:09:05 -0700
Local: Wed,May 4 2005 5:09 pm
Subject: Re: WML PHP login page
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

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 #1
Share this Question
Share on Google+
4 Replies


P: n/a
XP wrote:
if(mysql_affected_rows()==0){
print"no such login in the system";
exit();
}


This and the previous exit cause the WML page to be invalid, because the
closing <p>, <card> and <wml> tags will be missing.

Try something like the following instead:

<!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
....
$result = @mysql_query($query);
if (!$result) {
print mysql_error();
}
else if (mysql_affected_rows()==0) {
print "no such login in the system";
}
else {
print "successfully logged into system";
print "<b> output....<b> <br>";
print "$password";
}
?>
</p>
</card>
</wml>
JW

Jul 17 '05 #2

P: n/a
Janwillem Borleffs wrote:
print "successfully logged into system";
print "<b> output....<b> <br>";
print "$password";
}


Replace the following line:

print "<b> output....<b> <br>";

With:

print "<b> output....</b> <br />";
JW

Jul 17 '05 #3

P: n/a
XP

Janwillem Borleffs wrote:
Janwillem Borleffs wrote:
print "successfully logged into system";
print "<b> output....<b> <br>";
print "$password";
}


Replace the following line:

print "<b> output....<b> <br>";

With:

print "<b> output....</b> <br />";
JW

Thanks for that. But, what I am trying to do is to redirect the user,
once they are logged in. I want to place either an automatic forward to
another page or to place a link to another page so that once the user
is logged on, they can move on to the next stage. If I use wml here,
obviously it does not work. Do I need to put a series of /'s around the
code?

Jul 17 '05 #4

P: n/a
XP wrote:
Thanks for that. But, what I am trying to do is to redirect the user,
once they are logged in. I want to place either an automatic forward
to another page or to place a link to another page so that once the
user is logged on, they can move on to the next stage. If I use wml
here, obviously it does not work. Do I need to put a series of /'s
around the code?


On the same page:

<?php
// connect to mysql database
....
$result = @mysql_query($query);
if (!$result) {
$message = mysql_error();
}
else if (mysql_affected_rows()==0) {
$message = "no such login in the system";
}
else {
header("Location: newpage");
exit;
}
?>
<!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 print $message ?>
</p>
</card>
</wml>
JW

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.