1
votes

I am new to Phone GAP and want to deploy my ported APP from PHP, google CloudSQL to win phone store 8.1. I have developed a Web Application using cordova with the following requirements

Front End: PhoneGap (Cordova)- HTML,JQUERY(given online jquery support links).

Back End: Google Cloud SQL- access via PHP using Jquery AJAX Call.

For Win Phone 8.1 Support, I need to upload in Win Phone App Store.

Should I use Phone Gap for Win Mobile or Any other technology, as I want this app to be deployed in Win Phone Store and used in Win Phone 8.1.

Sample Script:

1.index.html

<!DOCTYPE html>
<html>
    <head>
        <title>sample phonegap</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- online jquery support links -->

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<!-- script for request page -->

 <script type="text/javascript" src="request.js"></script>

</head>
<body>
<div id="landmark-1" data-landmark-id="1">
    <form method="post">
        <label for="email"> // Email id as input
            <b>Email</b>
            <input type="email" id="email" name="email">
        </label>
        <label for="comment">// comments as input
            <b>Comment</b>
            <textarea id="comment" name="comment" cols="30" rows="10"></textarea>
        </label>
        <input type="submit" value="Save" id="save">
    </form>
</div>
</body>
</html>
  1. Input given by user sent to back end via AJAX request to PHP page.

request.js

    $(document).ready(function() {
       $('form').submit(function(){

            var landmarkID = $(this).parent().attr('data-landmark-id');
            var postData = $(this).serialize();
            $.ajax({
                type: 'POST',
                url: "save.php",
                data: postData+'&lid='+landmarkID,
                success: function(data)
                {
                    alert(JSON.parse(data));
                    $('form')[0].reset();
                },
                error: function(data){
                    alert('There was an error adding your comment'+JSON.stringify(data));
                }
            });

return false;
        });
    });

3.In PHP page, Input given by User saved in Google Cloud SQL.

save.php

<?php

**//connection parameters**

$server = "IP";

$username = "";

$password = "";

$database = "";

$con=new mysqli($server,$username,$password,$database); **//connect to db**

$locationID = $_POST["lid"];

$email = mysqli_real_escape_string($con,$_POST["email"]);

$comment = mysqli_real_escape_string($con,$_POST["comment"]);

$sql = "INSERT INTO comments (location_id, email, comment) "; **//insert values in table**

$sql .= "VALUES ($locationID, '$email', '$comment')";

$result="";

if (!mysqli_query($con,$sql)) {

    die('Error: ' . mysqli_error($con));

} else {
        $result="SUCCESS";
}

echo json_encode($result);  **//return result to front end**

?>

Create Table Query:

Table name: comments

CREATE TABLE `comments` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `location_id` int(11) DEFAULT NULL,
  `email` varchar(45) DEFAULT NULL,
  `comment` text,
  PRIMARY KEY (`id`)
)

Is above process of coding correct to support for Win App and may I know the process of steps to upload in Win Store?

Will this Work in Win Phone 8.1 after successful upload in Win Store? Will someone give sample script to support for Win phone 8.1?

1
Will Anyone Pls reply?Sattanathan

1 Answers

0
votes

I'm not sure if you have resolved this issue yet or not.

I'd suggest sticking with Phonegap. I would put that save.php file somewhere on your server and not bundle it with your app. PHP can't run in a phonegap app so you'll have to keep it external from your app files. Just change the url in the "url: " part of your ajax statement to the full url where save.php is located.