Connecting Tech Pros Worldwide Forums | Help | Site Map

Passing parameters wml, php, mysql

Newbie
 
Join Date: Mar 2008
Posts: 4
#1: Mar 5 '08
Hi guys,

I want to basically take in a username and password and then check to see if its in the mySQL database. The problem is though that I can print the variables yet when I use then in the php query the resultSet is null. If I force the values though the resultSet is not null. If anyone has any ideas on how I can fix this can you let me know ASAP.

Any help would be greatly appreciated.

Heres my code:
[PHP]
print "<wml>\n";
print "<card title=\"home\" id = \"main\">\n";
print "<p align = \"center\">\n";
print "Username: <input name=\"username\" size = \"10\"/>\n";
print "</p>\n";
print "<p align = \"center\">\n";
print "Password: <input name=\"password\" size = \"10\"/>\n";
print "</p>\n";
print "<p align = \"center\">\n";
print "<a href=\"#results\">Submit</a>\n";
print "</p>\n";
print "</card>\n";

print "<card id=\"results\">\n";
print "<p>\n";
print "<u>$(username)</u>\n";
print "<u>$(password)</u>\n";
print "</p>\n";
$link_id = mysql_connect("xxxxx, "xxxxx", "xxxx");

if(mysql_select_db("xxxx", $link_id))
{
print "<p>Connected to MySQL database...</p>n";

$query = "SELECT cust_id FROM customer where username = '$(username)'";


$result = mysql_query($query,$link_id);
$num_rows = mysql_num_rows($result);
print "<p>$num_rows</p>n";
if($num_rows == 0)
{
print "<p>ERROR</p>n";
}
else
{
print "<p>OK</p>n";
}
}
else
{
print "<p>Error in connection....</p>n";
}


print "</card>n";
print "</wml>n"; [/PHP]

Thanks a million in advance,

Shauna

markmcgookin's Avatar
Moderator
 
Join Date: Dec 2006
Location: Northern Ireland / England
Posts: 546
#2: Mar 5 '08

re: Passing parameters wml, php, mysql


I have moved this to the PHP forum because I think you will get a better response here
Newbie
 
Join Date: Mar 2008
Posts: 4
#3: Mar 5 '08

re: Passing parameters wml, php, mysql


Thanks for that Mark.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Mar 5 '08

re: Passing parameters wml, php, mysql


You have to submit the user and password variables to the php script and from there 'catch' and validate them. You must therefore submit the form (you have no form defined), passing the userid/password. The process is something like.
Expand|Select|Wrap|Line Numbers
  1. IF form is submitted
  2.   get variables from $_POST array
  3.   check validity in database
  4.   if valid then continue other process
  5. EndIF
  6. FORM action=POST method=this script
  7.   INPUT username
  8.   INPUT password
  9.   SUBMIT
  10. EndFORM
Ronald
Newbie
 
Join Date: Mar 2008
Posts: 4
#5: Mar 5 '08

re: Passing parameters wml, php, mysql


Hi,

Thanks for your reply. My problem now is that the form never submits. The code always prints no name. Here's my code:

[PHP]print "<wml>\n";
print "<card title=\"home\" id = \"main\">\n";
print "<onevent type=\"onenterbackward\">\n";
print "<refresh>\n";
print "<setvar name=\"username\" value=\"\"/>\n";
print "<setvar name=\"password\" value=\"\"/>\n";
print "</refresh>\n";
print "</onevent>\n";
print "<p align = \"center\">\n";
print "UsernameT: <input name=\"username\" size = \"10\"/>\n";
print "</p>\n";
print "<p align = \"center\">\n";
print "Password: <input name=\"password\" size = \"10\"/>\n";
print "</p>\n";
//print "<anchor>\n";
print "<do type=\"accept\" label=\"Submit\">\n";
print "<go method=\"post\" href=\"#results\">\n";
print "<postfield name=\"username\" value=\"$(username)\"/>\n";
print "<postfield name=\"password\" value=\"$(password)\"/>\n";

print "</go>\n";
print "</do>\n";
//print "</anchor>\n";

print "</card>\n";

//code to print data
print "<card title = \"checker\" id=\"results\">\n";

if (isset($_POST['submit']))
{
$name = $_POST["username"];
}
else
{
print "<p>no name</p>\n";
}
etc....[/PHP]
Newbie
 
Join Date: Mar 2008
Posts: 4
#6: Mar 5 '08

re: Passing parameters wml, php, mysql


Hi,

I just wanted to let you know that I fixed my problem! Thanks again for your help. It was greatly apprecitated!!!!!


Shauna
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#7: Mar 5 '08

re: Passing parameters wml, php, mysql


You are always welcome at the Scripts. See you next time.

Ronald
Reply