Guidelines for uploading an Android and iOS application that includes MySQL/PHP integration and packaging it with PhoneGap

I am developing an Android and iOS app using HTML, CSS, PHP to interact with MySQL database through JSON for integration with PhoneGap. All functionalities work smoothly on a browser, but I'm unsure how to upload the app and its server-side functions to a GitHub repository in order to utilize PhoneGap cloud services. With previous apps that did not involve MySQL, I simply uploaded the code to GitHub.

If I were to host the MySQL database on a remote server and the app code on GitHub, how can I establish a connection between them?

Below is my PHP script for database connection:

<?php
header('Access-Control-Allow-Origin: *');

$user="root";
$pass="xxxx";
$dbh = new PDO('mysql:host=localhost;dbname=uxxxmobile', $user, $pass);
?>

Here is my login function:

<script>
$(document).ready(function(){
    $('#loginForm').on('submit',function(e){

        var myForm = new FormData($(this)[0]);
        var host = 'http://example.com/uixxxmobile/connections';

        $.ajax({
            type:'POST',
            url: host + '/login.php',
            data : new FormData($(this)[0]),
            cache: false,
            contentType:false,
            processData: false,
            beforeSend: function(){
                $("div#divLoading").show();
            },
            success: function(response){
                $("div#divLoading").hide();
                console.log(response);
                if(response.success == true)
                {
                    window.location.href = "profile.html";
                }

                else if( response.success == false ){
                    alert('please enter a correct email & password');
                }
                else if(response.matric =="") {
                        alert('email is wrong');
                    }
                    else if(response.password==""){
                        alert('password is wrong');
                    }

            },
            error: function(data){
                alert('Login fail. Check your login details correctly');
                $("div#divLoading").hide();
            }
        });
    return false;
    });
});
</script>

And here is my profile function:

<script>
$(document).ready(function(){

    var host = 'http://example.com/uixxxmobile/connections';

    $.ajax({
        type: 'GET',
        url: host + '/profile.php',
        data: 'param=no' ,
        dataType: 'JSON',
        success: function (response) {
            console.log(response);
            var input ="";
            input +='<b>' + response.name + '</b><br>';
            input += response.faculty + '<br>';
            input += response.dept + '<br>';
            input +=response.school + '<br>';

            var cumgrade= response.cumgpa;
            var currentgrade= response.currentgpa;
            $('#basicContent').html(input);
            $('#cumgpa').html(cumgrade);
            $('#currentgpa').html(currentgrade);
            $('#level').html(response.level + ' Level ' +response.semester+ ' Semester')
        },
        error: function (e){
            alert (e);
        }
    });

    $('#mycourses').load('connections/user-course.php');

});
</script>

Answer №1

To create a link via ajax call, I typically utilize ajax within jQuery in my application:

var website = 'insert your website address - for instance: https://example.com/php/';

$.ajax({
    url: website + "/driverlogin.php",
    type: 'POST',
    cache: false,
    data: $('#frmdriverlogin').serialize(),
    success: function(response) {//process successful response}, 
    error: function(){//handle errors}   
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Running a Node Fetch POST call with a GraphQL query

I'm currently facing an issue while attempting to execute a POST request using a GraphQL query. The error message Must provide query string keeps appearing, even though the same request is functioning correctly in PostMan. This is how I have configur ...

Retrieving user information from the database and adding it to the specified element

I've been grappling with what seems like a simple question for the past hour. Below is a script that I have which pulls all active reservations from the reservations table. require("../includes/connect.php"); function dispAllReservations(){ $i= ...

Tips for launching and troubleshooting an AngularJS application within Eclipse

Looking to dive into Nodeclipse and get up and running with debugging an AngularJS application like the angular-phonecat example from Eclipse. Specifically, I want to utilize a Debug on Server launcher to kick off a server with my app and launch a web b ...

Tap on the child to reveal their parent

I am working with a family tree that includes dropdown menus containing the names of parents and children. Each child has a link, and when I click on a child's link, I want their father to be displayed in the dropdown menu as the selected option. Can ...

Display only one collapse open at a time using Vue 3 and Bootstrap 5

I am currently utilizing Bootstrap5 and Vue 3. In my project, I have several buttons, each of which triggers a different collapse. My goal is to have only one collapse open at a time, meaning that when I open one collapse, all the others should close. How ...

How can I make an AJAX request in Rails 3 to retrieve an HTML page?

I am experimenting with using Rails to display an .html.erb template via an ajax request under specific conditions. By default, I am consistently receiving the .js.erb file when making an ajax request. Without delving into the reasons behind this choice, ...

I am having an issue where my div element is not inheriting the width of its

I am encountering an issue where I have one div and I check the width of that div in jQuery. I then try to set the same width on the next div, but the width does not appear. Can someone please assist me with this? Here is my code: $(document).ready(funct ...

Is there a way to retrieve all images stored in this Firebase JSON database?

Image Link in JSON I am looking to retrieve all images from my Firebase database using the following code snippet: FirebaseDatabase database = FirebaseDatabase.getInstance(); database.getReference("actors").addValueEventListener(new ValueEventListe ...

json output displaying data in rows without specific keys

I'm currently facing a challenge with mapping the "url" and "failedCount" data from the columns section of my JSON sample to each row in the rows section. My goal is to then export this mapped data into a CSV format, similar to the example below: url, ...

The anchoring scroll position is incorrect due to the constantly changing content

Within my HTML document, there is an element identified by the #pro-plan id. Upon visiting the URL localhost:3000/#pro-plan, the page successfully scrolls to the designated section; however, at times it may end up in the wrong position. One possible expl ...

Bootstrap3 Remote Modal experiencing conflict due to Javascript

Utilizing a bootstrap modal to showcase various tasks with different content but the same format is my current goal. However, I am encountering an issue when attempting to make the textareas editable using JavaScript. The conflict arises when I open and cl ...

Blurring a section of a circular image using a combination of CSS and JavaScript

I'm trying to achieve a specific effect with my circular image and overlaying div. I want the overlaying div to only partially shade out the image based on a certain degree value. For example, if I specify 100 degrees, I only want 260 degrees of the c ...

Encountering an issue with Spring and AngularJS, as I am receiving an HTTP Status 404 error message

I'm encountering an HTTP Status 404 error within my controller. Server code @RequestMapping(value="/showMsg/", method=RequestMethod.GET,produces= { "application/json" })' public ResponseBody String show(){ HashMap hash = new HashMap(); ...

Is there a way to determine the bounding rectangle of a specific word within a paragraph when you only have its index?

I am currently developing a text-to-speech functionality for a react application that can emphasize the word being spoken by highlighting it with a background color. This feature closely resembles the layout of the Firefox reader view. However, my curren ...

Employ the vue.js method within the click EventListener of another method

In my Vue.js script, I have a method that generates an element called 'lens'. Now, I want to include an EventListener that triggers another method when the lens element is clicked. The problem: I have attempted two different approaches to add ...

Rendering illuminated component with continuous asynchronous updates

My task involves displaying a list of items using lit components. Each item in the list consists of a known name and an asynchronously fetched value. Situation Overview: A generic component named simple-list is required to render any pairs of name and va ...

The optimal method for selecting a button from a group of buttons on a calculator using pure JavaScript

I have developed an HTML/CSS code inspired by the Mac/Apple calculator design. It features buttons organized in 5 rows using flexbox. You can view my code on this codepen: <div class="wrapper"> <div class="calheader"> ...

Combining Angular with Node.js (Express) and MySQL

Is there a way to effectively integrate all these components? For instance, I have a straightforward database with one table (ID, text, done) and a code for exporting data from mySQL to a JSON file. The JSON file structure is as follows: [{ "id":"1", "tex ...

The clearing of sessions is not supported by Node.js / Express.js

At the start, the application loads some users using Angularjs / $http.get(). As you scroll down, more users are loaded dynamically (infinite scroll). In addition to this, there are location filters on the page. Users can select a different Country and Ci ...

Encountering Zip File Corruption Issue post MongoDB Download

My goal is to attach a zip file to an object and request the zip file when the object is called from the client. I was successful in uploading the zip file using the following code: const upload = multer({ fileFilter(req, file, cb){ if (!file. ...