Passing parameters wml, php, mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shauna00
    New Member
    • Mar 2008
    • 4

    Passing parameters wml, php, mysql

    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>Connect ed to MySQL database...</p>n";

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


    $result = mysql_query($qu ery,$link_id);
    $num_rows = mysql_num_rows( $result);
    print "<p>$num_ro ws</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
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    I have moved this to the PHP forum because I think you will get a better response here

    Comment

    • shauna00
      New Member
      • Mar 2008
      • 4

      #3
      Thanks for that Mark.

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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.
        Code:
        IF form is submitted
          get variables from $_POST array
          check validity in database
          if valid then continue other process
        EndIF
        FORM action=POST method=this script
          INPUT username
          INPUT password
          SUBMIT
        EndFORM
        Ronald

        Comment

        • shauna00
          New Member
          • Mar 2008
          • 4

          #5
          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=\"onenterb ackward\">\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=\"$(usern ame)\"/>\n";
          print "<postfield name=\"password \" value=\"$(passw ord)\"/>\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]

          Comment

          • shauna00
            New Member
            • Mar 2008
            • 4

            #6
            Hi,

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


            Shauna

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

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

              Ronald

              Comment

              Working...