Advertisement
Guest User

Untitled

a guest
Mar 20th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. <br />
  2. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  3. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant student_id - assumed 'student_id' in C:wamp64wwwfetchuserdata.php on line <i>17</i></th></tr>
  4. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  5. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  6. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>241296</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:wamp64wwwfetchuserdata.php' bgcolor='#eeeeec'>...fetchuserdata.php<b>:</b>0</td></tr>
  7. </table></font>
  8. <br />
  9. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  10. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant student_id - assumed 'student_id' in C:wamp64wwwfetchuserdata.php on line <i>17</i></th></tr>
  11. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  12. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  13. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>241296</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:wamp64wwwfetchuserdata.php' bgcolor='#eeeeec'>...fetchuserdata.php<b>:</b>0</td></tr>
  14. </table></font>
  15. <br />
  16. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  17. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant student_id - assumed 'student_id' in C:wamp64wwwfetchuserdata.php on line <i>17</i></th></tr>
  18. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  19. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  20. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>241296</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:wamp64wwwfetchuserdata.php' bgcolor='#eeeeec'>...fetchuserdata.php<b>:</b>0</td></tr>
  21. </table></font>
  22. <br />
  23. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  24. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant student_id - assumed 'student_id' in C:wamp64wwwfetchuserdata.php on line <i>17</i></th></tr>
  25. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  26. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  27. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>241296</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:wamp64wwwfetchuserdata.php' bgcolor='#eeeeec'>...fetchuserdata.php<b>:</b>0</td></tr>
  28. </table></font>
  29. <br />
  30. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  31. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant student_id - assumed 'student_id' in C:wamp64wwwfetchuserdata.php on line <i>17</i></th></tr>
  32. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  33. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  34. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0005</td><td bgcolor='#eeeeec' align='right'>241296</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:wamp64wwwfetchuserdata.php' bgcolor='#eeeeec'>...fetchuserdata.php<b>:</b>0</td></tr>
  35. </table></font>
  36. {"student_id":10381109,"fname":"Jack":"lname":"Finan","username":"123","password":"123"}
  37.  
  38. public class MainActivity extends AppCompatActivity implements View.OnClickListener
  39. {
  40.  
  41. TextView responseView;
  42. EditText etUsername;
  43. EditText etPassword;
  44. ProgressBar progressBar;
  45. Button bLogin;
  46. static final String SERVER_ADDRESS = "http://192.168.1.11:8080/";
  47.  
  48. @Override
  49. protected void onCreate(Bundle savedInstanceState)
  50. {
  51. super.onCreate(savedInstanceState);
  52. setContentView(R.layout.activity_main);
  53.  
  54. responseView = (TextView) findViewById(R.id.responseView);
  55. etUsername = (EditText) findViewById(R.id.etUsername);
  56. etPassword = (EditText) findViewById(R.id.etPassword);
  57. progressBar = (ProgressBar) findViewById(R.id.progressBar);
  58. bLogin = (Button) findViewById(R.id.bLogin);
  59. bLogin.setOnClickListener(this);
  60.  
  61. }
  62.  
  63. @Override
  64. public void onClick(View v)
  65. {
  66. switch(v.getId()){
  67. case R.id.bLogin:
  68. String username = etUsername.getText().toString();
  69. String password = etPassword.getText().toString();
  70.  
  71. User user = new User(username, password);
  72.  
  73. getUser(user);
  74. break;
  75. }
  76. }
  77.  
  78. public void getUser(User user)
  79. {
  80. new GetJSONData(user).execute();
  81. }
  82.  
  83. class GetJSONData extends AsyncTask<Void, Void, String> // class to fetch javascript object data
  84. {
  85. User user; // variable
  86.  
  87. GetJSONData(User user) // constructor
  88. {
  89. this.user = user;
  90. }
  91.  
  92. protected void onPreExecute() // methods below
  93. {
  94. progressBar.setVisibility(View.VISIBLE);
  95. responseView.setText("");
  96. }
  97.  
  98. protected String doInBackground(Void... urls)
  99. {
  100.  
  101. HttpURLConnection connection = null;
  102. BufferedReader reader = null;
  103.  
  104. try {
  105. URL url = new URL(SERVER_ADDRESS + "fetchuserdata.php"); // the server we hit and the course code we want entered
  106. connection = (HttpURLConnection) url.openConnection(); // open connection
  107. connection.setRequestMethod("POST");
  108.  
  109. Uri.Builder builder = new Uri.Builder().appendQueryParameter("username", user.username).appendQueryParameter("password",user.password);
  110. String query = builder.build().getEncodedQuery();
  111. OutputStream os = connection.getOutputStream();
  112. BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os,"UTF-8"));
  113. writer.write(query);
  114. writer.flush();
  115. writer.close();
  116. os.close();
  117.  
  118. connection.connect(); // connect
  119.  
  120. InputStream stream = connection.getInputStream(); // create input stream of data
  121. reader = new BufferedReader(new InputStreamReader(stream)); // create buffered reader to help read input stream of data
  122.  
  123. StringBuilder buffer = new StringBuilder();
  124. String line;
  125.  
  126. while ((line = reader.readLine()) != null) {
  127. buffer.append(line).append("n");
  128. }
  129.  
  130. return buffer.toString();
  131. }
  132. catch(IOException e)
  133. {
  134. e.printStackTrace();
  135. }
  136. finally
  137. {
  138. if(connection != null)
  139. {
  140. connection.disconnect();
  141. }
  142. try
  143. {
  144. if(reader != null)
  145. {
  146. reader.close();
  147. }
  148. }
  149. catch(IOException e)
  150. {
  151. e.printStackTrace();
  152. }
  153. }
  154. return null;
  155. }
  156.  
  157. protected void onPostExecute(String result)
  158. {
  159. if(result == null) {
  160. result = "THERE WAS AN ERROR";
  161. }
  162. progressBar.setVisibility(View.GONE);
  163. Log.i("INFO", result);
  164. responseView.setText(result);
  165. }
  166. }
  167. }
  168.  
  169. <?php
  170. $con=mysqli_connect('localhost','root','164f9ogC!','user');
  171.  
  172. $username = $_POST["username"];
  173. $password = $_POST["password"];
  174.  
  175. $statement = mysqli_prepare($con, "SELECT * FROM user WHERE username = ? AND password = ?");
  176. mysqli_stmt_bind_param($statement, "ss", $username, $password);
  177. mysqli_stmt_execute($statement);
  178.  
  179. mysqli_stmt_store_result($statement);
  180. mysqli_stmt_bind_result($statement, $student_id, $fname, $lname, $username, $password);
  181.  
  182. $user = array();
  183.  
  184. while(mysqli_stmt_fetch($statement)){
  185. $user[student_id] = $student_id;
  186. $user[fname] = $fname;
  187. $user[lname] = $lname;
  188. $user[username] = $username;
  189. $user[password] = $password;
  190. }
  191.  
  192. echo json_encode($user);
  193.  
  194. mysqli_stmt_close($statement);
  195.  
  196. mysqli_close($con);
  197. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement