Phonegap remote login with MYSQL PHP example?

4,457 views
Skip to first unread message

Dustin LeBleu

unread,
Jul 24, 2013, 5:31:42 PM7/24/13
to phon...@googlegroups.com
I have scoured the internet looking for a simple login example that uses Phonegap with Dreamweaver to remotely connect to a php file and authenticate a user, then redirect the user to a profile page that also grabs data remotely with that user's credentials. 

Any help is greatly appreciated. Thank you!

rodu...@gmail.com

unread,
Jul 24, 2013, 6:05:52 PM7/24/13
to phon...@googlegroups.com
Please read the blog post from Raymond Camden's site on
Example of server-based login with PhoneGap - Raymond Camden also check this on his site
Update to my Server-Based Login PhoneGap Demo. They are very helpful.
Sent from my BlackBerry wireless device from MTN

From: Dustin LeBleu <vivid...@gmail.com>
Date: Wed, 24 Jul 2013 14:31:42 -0700 (PDT)
Subject: [PhoneGap] Phonegap remote login with MYSQL PHP example?

I have scoured the internet looking for a simple login example that uses Phonegap with Dreamweaver to remotely connect to a php file and authenticate a user, then redirect the user to a profile page that also grabs data remotely with that user's credentials. 

Any help is greatly appreciated. Thank you!

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dustin LeBleu

unread,
Jul 25, 2013, 3:28:11 PM7/25/13
to phon...@googlegroups.com, rodu...@gmail.com
Hi Rachelle,

Thanks for writing me. I noticed Ray's work is using old api's (cordova) and is talking to a coldfusion server. I wish I could find someone who has a php mysql simple login tool so I can see it working. So odd how hard that is to find. 

Thanks again!

Dustin

Dean Hurley

unread,
Jul 28, 2013, 6:31:37 PM7/28/13
to phon...@googlegroups.com
Hi I am working on this now...

My approach requires me to authenticate with Joomla 2.5. Are you using a CMS or a bespoke server side solution?

Based on your response I will give a more in-depth reply...

Dean
Datalynk

SAURABH CHADHA

unread,
Aug 30, 2013, 5:08:47 PM8/30/13
to phon...@googlegroups.com, rodu...@gmail.com
Hii,

I am looking for the same....login with php mysql and redirect to a page.... help me if you have cracked it

thanks

Lukas Menges

unread,
Sep 19, 2013, 3:44:22 AM9/19/13
to phon...@googlegroups.com
Take the example of rays and post to your own webservice written in PHP. This is mine:

<?php


include
"db.php";
$username
=$_POST["username"];
$password
=$_POST["password"];


$sql
="SELECT username, password FROM user_app WHERE username = '".$username."' AND password = '".$password."'";


$result
= mysql_query($sql);


if (mysql_num_rows($result) < 1){
 echo
'false';
}else{
 echo
'true';
}


mysql_close
($con);
?>

Ronald K

unread,
Sep 19, 2013, 4:57:33 AM9/19/13
to phon...@googlegroups.com
$username=$_POST["username"];
$password=$_POST["password"];
$sql="SELECT username, password FROM user_app WHERE username = '".$username."' AND password = '".$password."'";

I'd strongly advise to escape user input with mysql_real_escape_string(), otherwise your app is open to SQL injection:

$sql="SELECT username, password FROM user_app WHERE username = '". mysql_real_escape_string($username) ."' AND password = '". mysql_real_escape_string($password) ."'";

Héctor Santos

unread,
Sep 19, 2013, 5:14:47 AM9/19/13
to phon...@googlegroups.com
I recomend you use jquery mobile to do the login by ajax...

This is a example:

function checkLogin(userLogin, passLogin){
    var request = $.ajax({
        url: "http://www.yourweb.com/api.php",
        type: "GET",
        data: { user : userLogin, password : passLogin },
        dataType: "json",
        beforeSend : function(){
            $.mobile.loading('show',{ theme: "b" });
        }
    });

    // RESPONSE
    request.done(function(data) {
        $.mobile.loading('hide');

        // The data["status"] == 'ok' is the echo in json that you send in your PHP to say if the login is correctly or not
        //
        // Ej of PHP:
        // $query = mysql_num_rows(mysql_query("SELECT * from users WHERE user = '".$_GET["user"]."' AND password = '".$_GET["password"]."'"));
        // if($query == 1){
        //      $data["status"] = "ok";
        //      echo json_encode($data);
        // }else{
        //      $data["status"] = "nok";
        //      $data["msg"] = "Login incorrect, try again"
        //      echo json_encode($data);  
        // }

        if(data["status"] == "ok"){

            // If the status is OK, you load the screen that do you want
            $.mobile.changePage($("#index"),{ transition: "slidedown"} );

        }else{

            // If the status is not ok, you show an alert and no change the login page
            navigator.notification.alert(data["msg"],false,'Error','Ok');
        }
    });
}

I hope I can help u.

Greetings from Spain ;)

toon lite

unread,
Mar 16, 2014, 12:27:16 PM3/16/14
to phon...@googlegroups.com, vivid...@gmail.com

Here i found great article on user login with backend code in phonegap. Please check http://www.toontuts.com/users-login-with-phonegap-and-jquery-mobile/
Thanks
Reply all
Reply to author
Forward
0 new messages