0

I am trying to create an app on android which makes users login in and I am using phonegap. Here is my code but when i run it i get an error

here is my index.html

<html>
<head>
<script type="text/javascript"  src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" >
function login() {
$(document).ready(function() {
var user = $("#user")[0].value;
var pass = $("#pass")[0].value;
$.ajax({
type:"GET",
url:"newlogin.php",
data: "user="+user+"&pass="+pass,
success: function(result){
if (result){
$("#message")[0].value = "Success "+result;
}
else {
$("#message")[0].value = "error";
}
}
});
});
}
</script>
<style type="text/css">
body{
margin:auto;
width:100%;
display: table;
background-color: #333;
}
form{
text-align: center;
height: 500px;
display: table-cell;
vertical-align: middle;
}
input{
font-size: 20px;
text-shadow: #ccc 2px 2px;
text-align: center;
}
input#message {
background-color: transparent;
border: 0;
color: white;
text-shadow: #5191C1 2px 2px;
}
</style>
</head>
<body>
    <form>
    <input type="text" size="25" id="user" onkeyup= "login()" />
    <br />
    <input type="text" size="25" id="pass" onkeyup= "login()"/>
    <br />
    <input type="text" size="25" id="message" value="hey" />
    </form>

</body>
</html>

and here is the newlogin.php it connects to

<?php 
$user = $_REQUEST['user'];
$pass = $_REQUEST['pass'];

mysql_connect("localhost","root","sercet") or die(mysql_error());
mysql_select_db("book") or die(mysql_error());

$result = mysql_query("SELECT username,password,id FROM book_users WHERE username = '$user'");
while($row = mysql_fetch_array($result)) {
    if($pass == $row["password"]){
        echo $row["id"];
        } 
        else {
            echo "";
            }

    }

?>

I hope you code help me find the solution to this problem

I Get the error at where it shows the message where it reads "Sucess + result" i get Sucess<?php user =$_REQUEST('user')....... <- thats all i could see in the emulator I am not sure if it might be that phonegap cannot execute php file

2
  • Bad question. What error do you get? How is anyone to know where to begin looking? Commented Jul 16, 2011 at 6:05
  • I am sorry,I tried to add a pic that showed the error but stack overflow wouldn't let me, but i did rewrite my question. Commented Jul 16, 2011 at 6:17

2 Answers 2

1

I am suspecting (because you use a local url for calling "your server" and you ask if phonegap can´t execute php) that you deployed a php file with your an to the phone. Phonegap can not execute php you need a server running php for that.

Sign up to request clarification or add additional context in comments.

Comments

0

Change your code:

url:"http://domainname/newlogin.php",

eg: for local (http://192.168.43.104/new/newlogin.php)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.