Advertisement
Guest User

Untitled

a guest
Feb 15th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <?php
  2. $db_name = "voyageurdb";
  3. $mysql_user = "root";
  4. $mysql_pass = "";
  5. $server_name = "localhost";
  6. $con = mysqli_connect($server_name ,$mysql_user ,$mysql_pass ,$db_name);
  7. if(!$con){
  8. echo "Connection error..".mysqli_connect_error();
  9. }else{
  10. echo "<h3>Database connection success...</h3>";
  11. }
  12. ?>
  13.  
  14. <?php
  15.  
  16. require"voyageur_init.php";
  17.  
  18. $Email = $_POST["txt_email"];
  19. $Password = $_POST["txt_password"];
  20. $sql_query = "Select name from user_info where user_name like '$Email' and user_pass like '$Password';";
  21. $result = mysqli_query($con, $sql_query);
  22.  
  23. if(mysqli_num_rows($result) > 0) {
  24. $row = mysqli_fetch_assoc($result);
  25. $First_name = $row["txt_firstname"];
  26. echo"Login Success...Welcome".$First_name;
  27. }else {
  28. echo"Login Faild...Try Again...";
  29. }
  30. ?>
  31.  
  32. <?php
  33.  
  34. require "voyageur_init.php";
  35.  
  36. $First_name = $_POST["txt_firstname"];
  37. $Last_name = $_POST["txt_lastname"];
  38. $Email = $_POST["txt_email"];
  39. $Phone_no = $_POST["txt_phone"];
  40. $Password = $_POST["txt_password"];
  41.  
  42. $sql_query = "insert into user_info values('$First_name ','$Last_name','$Email','$Phone_no','$Password');";
  43.  
  44. if(mysqli_query($con, $sql_query)) {
  45. //echo"<h3>Data Insertion Success...</h3>";
  46. }else {
  47. //echo"Data Insertion Error...".mysqli_error($con);
  48. }
  49. ?>
  50.  
  51. protected String doInBackground(String... params) {
  52. String reg_url = "asanka1055.byethost6.com/voyageur_register.php";
  53. String login_url = "asanka1055.byethost6.com/voyageur_login.php";
  54. String method = params[0];
  55. if(method.equals("Register")) {
  56. String firstname = params[1];
  57. String lastname = params[2];
  58. String email = params[3];
  59. String phone = params[4];
  60. String password = params[5];
  61. try {
  62. URL url = new URL(reg_url);
  63. HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
  64. httpURLConnection.setRequestMethod("POST");
  65. httpURLConnection.setDoOutput(true);
  66. OutputStream os = httpURLConnection.getOutputStream();
  67.  
  68. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  69. String data = URLEncoder.encode("firstname", "UTF-8") + "=" + URLEncoder.encode(firstname, "UTF-8") + " & " + URLEncoder.encode("lastname", "UTF-8") + "=" + URLEncoder.encode(lastname, "UTF-8") + " & " +
  70.  
  71. URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode(email, "UTF-8") + " & " + URLEncoder.encode("phone", "UTF-8") + "=" + URLEncoder.encode(phone, "UTF-8") + " & " + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode(password, "UTF-8");
  72.  
  73.  
  74. bufferedWriter.write(data);
  75. bufferedWriter.flush();
  76. bufferedWriter.close();
  77. os.close();
  78. InputStream is = httpURLConnection.getInputStream();
  79. is.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement