cordova - Connecting a phone app (phonegap) to a localhost file(in local machine) -


i creating phonegap mobile app(android).i have emulated app using phone.when registration on form in local machine , data submitted database.but when try same using phone nothing happens.the reason think phone can't reach loop address of machine.how can go this?

registration file (html)

<script type="text/javascript">      $(document).ready(function(){        $("#signup").click(function(){      var name = $("#name").val();      var email = $("#email").val();      var username=$("#username").val();      var password=$("#password").val();        // returns successful data submission message when entered information stored in database.      var datastring = 'name='+ name + '&email='+ email + '&username=' + username + '&password=' + password;        if(name==''|| email=='' || username=='' || password=='')      {          alert("please fill fields");      }      else      {          //ajax code submit form.          $.ajax({                  type: "post",                  url: "http://127.0.0.1/test/signup.php",                  data: datastring,                  cache: false,                  success: function(result){                                      alert(result);                                          }          });      }      return false;      });      });  </script>        <div class="app">          <div class="panel panel-primary">              <div class="panel-heading">                  <h3 class="panel-title">sign up</h3>              </div>              <div class="panel-body">                  <div class="form-group">                      <input type="text" name="name" id="name" class="form-control" placeholder="full name" required>                      <br>                      <input type="email" name="email" id="email" class="form-control" placeholder="email address" required>                      <br>                      <input type="text" name="username" id="username" class="form-control" placeholder="username" required>                      <br>                      <input type="password" name="password" id="password" class="form-control" placeholder="password" required>                      <br>                      <input type="submit" id="signup" value="submit" class="btn btn-success">                  </div>              </div>              <b>or sign in <a href="#" class="btn btn-primary" data-toggle="modal" data-target="#login-mod">here</a></b>          </div>      </div>

signup file (php file)

<?php  header('access-control-allow-origin: *');  $con=mysqli_connect("localhost","root","","test") or die("error in server");         	$name=$_post['name'];    	$email=$_post['email'];    	$username=$_post['username'];    	$password=$_post['password'];      	 $sql="insert signup(name,email,username,password) values('$name','$email','$username',sha1('$password')) ";    	 $qry=mysqli_query($con,$sql) or die(mysqli_error($con));       if($qry){echo "registration successful.";}       else echo "a network error occured.please retry.";      ?>

if using local network use local network ip address.and make sure firewall off.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -