|
|
|
usernames และ passwords เมื่อกรอกข้อมูลจากมือถือจากนั้นกด login ข้อมูลตัวแปร urlParameters และ urlParameters2 ส่วน +usernames และ passwords เป็นค่าว่างทำให้ login ไม่ได้ แก้ไขตรงส่วนไหนครับ |
|
|
|
|
|
|
|
ลองประยุกต์้พวก Library นะครับ น่าจะจัดการกับพวกตัวแปรง่ายขึ้นครับ
Android HTTP Library (HTTP Library)
|
|
|
|
|
Date :
2017-09-19 18:28:01 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมเพลองเพิ่ง code ช่อง input รับค่าได้แล้วครับแต่ติดตรงจะส่งค่า u และ p ไปที่ doInBackground ได้อย่างไร
Code (Android-Java)
public class MainActivity extends Activity {
private ProgressDialog progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
///////////////////////////////////////////////////////////
//TextBox
final EditText username = (EditText)findViewById(R.id.username);
//TextBox2
final EditText pass = (EditText)findViewById(R.id.pass);
//Submit Button
final Button subMitfrm = (Button)findViewById(R.id.sendPost);
//Value Text
final TextView showMsg = (TextView)findViewById(R.id.textView3);
//Click Event
subMitfrm.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String u = username.getText().toString();
String p = pass.getText().toString();
showMsg.setText("Your Name:"+value+" : "+value2);
}
});
///////////////////////////////////////////////////
}
Code (Android-Java)
protected Void doInBackground(String... params) {
try {
String u;
String p;
final TextView outputView = (TextView) findViewById(R.id.showOutput);
URL url = new URL("http://148.107.102.22/process.php");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String urlParameters = "form_account=".concat(u);
String urlParameters2 = "form_password=".concat(p);
|
|
|
|
|
Date :
2017-09-20 11:08:14 |
By :
mininovaa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|