How to Connect Android App with a Local Web Sever using wifi - php

Android app Connectivity with Local Web Server
I want to connect my android app with local web server to access my php files and store data into web server database.
I also tried to use free hosting web site 000webhost.com but their database didn't provide me InnoDB DB engine, They have MYISAM which doesn't provide foreign key property...
please suggest me any solution for this issue...??

1、you can connect to you local web server through 127.0.0.1/yourproject/path
2、check you ip, like 192.168.0.110 etc.
3、try to access 192.168.0.110/youproject/path in your phone browser.
if you can access in you browser, that's your testing address

If using windows get your server ip by running:
ipconfig
in the Command Prompt. Then search for IPv4 that is your server ip;
If Using Linux Use:
ifconfig
in terminal. Then get inet addr field in wlan0.
Now you have ip address of server.
Use it as: http://yourserveripadress

Related

connect to mysql using php vpn

I have a php script that accesses a mysql database. It lives on a server that has been migrated to aws (amazon web services). This server hosts a website that used to live on a physical server part of a private network.
The databases are still on that private network. I need to connect to a mysql database that is on a server with no public ip address. There is a vpn set up for this network.
I would like to ssh or vpn to the network from the aws server.
This is just to query something once a day.
I tried exec('ssh -f -L 3307:PrivateMYSQLServer:3306 USER#VPNADDRESS') but could not get it to work.
Is there a one liner that I can insert into the php script?
thanks
You’ll have to set up the server in which your script runs to connect back to your network via your VPN client.
Alternatively, you can set up a site to site VPN between your data center and AWS.
If you have a correctly configured site-to-site VPN (and routing tables, security groups, etc.), one end in your VPC and the other end in your private on premises network, then you don't need to create an SSH tunnel. Just connect to your database and run the query.

Connecting local php server with android devices

To connect local php website, i was able to connect from another pc in the same network by using ipaddress/foldername (eg. 192.168.1.1/test). I want to know that can i connect from android phone in the same wifi using the same method.
You could also use ngrok for this:
https://ngrok.com/
ngrok allows you to create a globally accessible domain name which directs to your local pc, especially useful for development.
As your device in the same local network, it will connect to your local website on your way

ios access localhost from real device

I have a local php(Laravel) server. I can access the domain "mydomain.dev" from an simulator but it does not work when I try to access it from a real device. I have the app running with the device connected to the same wifi network but it still does not work.
Open your command prompt/terminal
Type
windows ipconfig
linux ifconfig -a or ip addr show
write your IPv4 adress
exemple (windows)
Then Run your server php artisan serve or whatever you are using (wamp/laragon or easyphp ..etc)
then go to your browser in your phone and navigate to mydomain.dev
This should work.
Please try to use IP address instead of mydomain.dev. When running on a real device, it will search dns server to look up mydomain.dev. If the dns server can't recognize this url, your device can't open it.

Connecting Android device to Apache server

I have created a database and trying to access it using php. I execute these scripts from my phone. Now the issue is that when I try to perform any operation on the DB from the real device (my MOBILE PHONE) it says "unfortunately Closed" but works fine from the virtual device.
URL for real android device:
[http:// 127.0.0.1:8888 //android_connect/get_product_details.php]
URL for the virtual device:
[http:// 10.0.2.2 /android_connect/get_product_details.php]
The 127.0.0.1 is a loopback address so the android device or any other computer will not able to connect to it. Get a webserver (there's a lot freely available to test PHP scripts) , drop all the files in there and you will be able to access it.
say.. http://somefreewebhost.com/android_connect/get_product_details.php
Alternatively...
If you are using a webserver like WAMP, you will have an option called "Put Online". Go to your command prompt and type "ipconfig" and note down that IP address and you can even use that (provided if you are not behind any firewall)

Android ip to connect to PC

I'm confused..
I'm using XAMPP in my PC to create a local server that has a few php scripts that connects to a mysql database (also on my local server) and receive data and then send this data to my android application..
My question is about the android app, what IP should I give in the HttpPost to connect my PC and access the php script ?
Should I use the IP of my machine followed by the :port and the path to the php file or should I use only 10.0.2.2 and the path to the file ? I pretend to test this app in my real device, not in emulator.
If your android device and local computer are on same wifi router, you can run ipconfig (windows) or ifconfig (linux) to have the IP address of your computer on the network of the router (generally wtarting with 192.168.x.x)
You should use this IP address to connect from your Android device to your computer.
Note : Be sure your ports are open on your computer to let the phone connect to your computer

Categories