php - App is not working on WAMP but It works in online server -


i made basic login app using online sqlite database(http://demo3534535.16mb.com) works fine on online server. want run on local server using wamp in gennymotion emulator.

what change in code have do? working online code is:

dbconnect.php

<?php     define('host','mysql.hostinger.in');     define('user','u756_userd');     define('pass','pass345');     define('db','u754113_demo');      $con = mysqli_connect(host,user,pass,db) or die('unable connect'); 

mainactivity.java

 public class mainactivity extends appcompatactivity implements view.onclicklistener {     private static final string register_url = "http://192.168.1.102/user/register.php";      public static final string key_username = "username";     public static final string key_password = "password";     public static final string key_email = "email";       private edittext edittextusername;     private edittext edittextemail;     private edittext edittextpassword;      private button buttonregister;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          edittextusername = (edittext) findviewbyid(r.id.edittextusername);         edittextpassword = (edittext) findviewbyid(r.id.edittextpassword);         edittextemail= (edittext) findviewbyid(r.id.edittextemail);          buttonregister = (button) findviewbyid(r.id.buttonregister);          buttonregister.setonclicklistener(this);     }      private void registeruser(){         final string username = edittextusername.gettext().tostring().trim();         final string password = edittextpassword.gettext().tostring().trim();         final string email = edittextemail.gettext().tostring().trim();          stringrequest stringrequest = new stringrequest(request.method.post, register_url,                 new response.listener<string>() {                     @override                     public void onresponse(string response) {                         toast.maketext(mainactivity.this, response, toast.length_long).show();                     }                 },                 new response.errorlistener() {                     @override                     public void onerrorresponse(volleyerror error) {                         toast.maketext(mainactivity.this,error.tostring(),toast.length_long).show();                     }                 }){             @override             protected map<string,string> getparams(){                 map<string,string> params = new hashmap<string, string>();                 params.put(key_username,username);                 params.put(key_password,password);                 params.put(key_email, email);                 return params;             }          };          requestqueue requestqueue = volley.newrequestqueue(this);         requestqueue.add(stringrequest);     }      @override     public void onclick(view v) {         if(v == buttonregister){             registeruser();         }     } } 

db_connect.php

<?php     define('host','localhost');     define('user','');     define('pass','');     define('db','db_demo');      $con = mysqli_connect(host,user,pass,db) or die('unable connect'); 

register.php

<?php      if($_server['request_method']=='post'){          $username = $_post['username'];         $email = $_post['email'];         $password = $_post['password'];          require_once('dbconnect.php');          $sql = "insert volley (username,password,email) values ('$username','$email','$password')";           if(mysqli_query($con,$sql)){             echo "successfully registered";         }else{             echo "could not register";          }     }else{ echo 'error'; } 

i using internet via wifi

if you're going local, follow these steps:

  1. you need create wlan. open command prompt admin mode , type these commands:

    netsh wlan set hostednetwork mode=allow ssid=developmentlan key=yourpassword 

    press ok. execute following command:

    netsh wlan start hostednetwork 

this shall start wlan.

now type ipconfig in command line, discover machine's ipv4 address:

ipconfig

edit:

make sure noting wireless lan adapter's ipv4 address.

note ip address. 1 going use host address.

the configuration part.

change define('host','mysql.hostinger.in');

to this define('host','localhost');

as rest, need change user's name, password , database name wampserver's username , password , database 's name on wamp, respectively.

now suppose register.php file wrapped inside user folder in wamp projects directory (c:/wamp/www/user/register.php). change register_url's value this:

private static final string register_url = "http://192.168.1.3/user/register.php"; 

and that's it, you're ready go. make sure firewall off, otherwise it block genymotion emulator connecting wamp server on machine, , change 192.168.1.3 machine's ip address.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -