Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. private void registerUser(){
  2. StringRequest stringRequest = new StringRequest(Request.Method.POST,
  3. URL_LOGIN,
  4. new Response.Listener<String>() {
  5. @Override
  6. public void onResponse(String response) {
  7. Toast.makeText(MainActivity.this,response,Toast.LENGTH_LONG).show();
  8. }
  9. },
  10. new Response.ErrorListener() {
  11. @Override
  12. public void onErrorResponse(VolleyError error) {
  13.  
  14.  
  15. Toast.makeText(MainActivity.this,error.toString(),Toast.LENGTH_LONG).show();
  16. }
  17. }){
  18. @Override
  19. protected Map<String,String> getParams()throws AuthFailureError{
  20. Map<String,String> params = new HashMap<String, String>();
  21. Cursor cursor=db.rawQuery(selectQuery,null);
  22. if (cursor.moveToFirst()) {
  23. do {
  24.  
  25.  
  26. //params.put("sid",cursor.getString(1));
  27. params.put("code",cursor.getString(2));
  28. params.put("answer", cursor.getString(3));
  29.  
  30.  
  31.  
  32.  
  33.  
  34. } while (cursor.moveToNext());
  35. }
  36.  
  37.  
  38. return params;
  39. }
  40.  
  41. };
  42.  
  43. RequestQueue requestQueue = Volley.newRequestQueue(this);
  44. requestQueue.add(stringRequest);
  45. }
  46.  
  47. $answer = $_POST['answer'];
  48. $code = $_POST['code'];
  49. //$sid=$_POST['sid'];
  50. //$useremail = $_POST['email'];
  51. //$userpassword = $_POST['password'];
  52. $user = "root";
  53. $pass = "";
  54. $host= "localhost";
  55. $dbname="offlinesurvey";
  56.  
  57. date_default_timezone_set('UTC');
  58. $date = date('YmdHis');
  59. //$name=$sid.'_'.$date;
  60. $con = mysqli_connect($host,$user,$pass,$dbname);
  61.  
  62.  
  63. $sql_create="CREATE TABLE `offlinesurvey`.`lime_survey_` ( `id` INT NULL AUTO_INCREMENT ,whenadded DATETIME, `code` VARCHAR(255) NOT NULL,`answer` VARCHAR(255) NOT NULL , UNIQUE `id` (`id`)) ENGINE = MyISAM;";
  64. if(mysqli_query($con,$sql_create)){
  65.  
  66. }
  67. else {
  68. "No..No";
  69. }
  70. $sql="insert into lime_survey_(whenadded,code,answer)
  71.  
  72. (Now(),'".$code."','".$answer."');";
  73. if(mysqli_query($con,$sql)){
  74. echo "data inserted";
  75.  
  76. }else{
  77. echo "Failed";
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement