Advertisement
Guest User

Untitled

a guest
Feb 15th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. $con = mysqli_connect("localhost" , "root" , "pass" , "databasename");
  3.  
  4. $name = $_POST["Name"];
  5. $email = $_POST["Email"];
  6. $username = $_POST["Username"];
  7. $password = $_POST["Password"];
  8.  
  9.  
  10. $insertquery = mysqli_prepare($con , "INSERT INTO contacts ( Name ,Email,Username,Password) VALUES (?,?,?,?)");
  11. mysqli_stmt_bind_param($insertquery , "ssss" , $name , $email , $username , $password);
  12. mysqli_stmt_execute($insertquery);
  13.  
  14.  
  15. mysqli_stmt_close($insertquery);
  16.  
  17. mysqli_close($con);?>
  18.  
  19. public class ServerRequests {
  20. ProgressDialog progressDialog;
  21. public static final int CONNECTION_TIMEOUT = 15000;
  22. public static final String SERVER_ADDRESS = "http://10.0.2.2/";
  23. /*
  24.  
  25. Some code here
  26.  
  27. */
  28. HttpParams httpRequestParams = new BasicHttpParams();
  29. HttpConnectionParams.setConnectionTimeout(httpRequestParams , CONNECTION_TIMEOUT);
  30. HttpConnectionParams.setSoTimeout(httpRequestParams , CONNECTION_TIMEOUT);
  31.  
  32. HttpClient client = new DefaultHttpClient(httpRequestParams);
  33. HttpPost post = new HttpPost(SERVER_ADDRESS + "Register.php");
  34.  
  35. /*HttpPost post = new HttpPost("http://10.0.2.2/Sites/phpmyadmin/Register.php");*/
  36.  
  37. try {
  38. post.setEntity(new UrlEncodedFormEntity(data_to_send));
  39. client.execute(post);
  40. }
  41. catch(Exception e)
  42. {
  43. e.printStackTrace();
  44. }
  45.  
  46. return null;
  47. }
  48.  
  49. @Override
  50. protected void onPostExecute(Void aVoid) {
  51. progressDialog.dismiss();
  52. callback.done(null);
  53.  
  54. super.onPostExecute(aVoid);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement