国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

android和PHP實(shí)現(xiàn)簡(jiǎn)單的登錄

2020-03-22 19:44:21
字體:
供稿:網(wǎng)友
先上效果:


2901931456-5b4815f83d443_articlex[1].png

說明:

1,使用 安卓手機(jī),或者模擬器
2,服務(wù)器支持php
3,簡(jiǎn)單驗(yàn)證登錄操作
4,網(wǎng)絡(luò)請(qǐng)求使用RxEasyHttp開源庫,是對(duì)okhttp3,retrofit的封裝,直接使用okhttp3也是可以的
5,測(cè)試登錄使用的url一直有效
6,需要服務(wù)器的,可以跟我合用,隨便打發(fā)幾塊軟妹幣都行,不限流量,不限空間。

服務(wù)器端php文件
 ?php //post方式,loginName,loginPwd相當(dāng)于是key $name = $_POST[ loginName  $pwd = $_POST[ loginPwd  if($name!= hello ){ die ( 用戶名錯(cuò)誤!  if($pwd != wode ){ die ( 密碼錯(cuò)誤!  echo 登錄成功! ? 
安卓端XML布局文件
 ?xml version= 1.0 encoding= utf-8 ?  android.support.constraint.ConstraintLayout xmlns:android= http://schemas.android.com/apk/res/android  xmlns:app= http://schemas.android.com/apk/res-auto  xmlns:tools= http://schemas.android.com/tools  android:layout_width= match_parent  android:layout_height= match_parent  android:padding= 4dp  tools:context= .MainActivity 
app:layout_constraintEnd_toEndOf= parent app:layout_constraintStart_toStartOf= parent app:layout_constraintTop_toTopOf= parent / EditText android:id= @+id/etPwd android:layout_width= match_parent android:layout_height= wrap_content android:layout_marginEnd= 8dp android:layout_marginLeft= 8dp android:layout_marginRight= 8dp android:layout_marginStart= 8dp android:layout_marginTop= 8dp android:hint= 請(qǐng)輸入密碼 app:layout_constraintEnd_toEndOf= parent app:layout_constraintStart_toStartOf= parent app:layout_constraintTop_toBottomOf= @+id/etName / Button android:layout_width= wrap_content android:layout_height= wrap_content android:layout_marginEnd= 8dp android:layout_marginLeft= 8dp android:layout_marginRight= 8dp android:layout_marginStart= 8dp android:layout_marginTop= 20dp android: quot;doLogin android:text= 登錄 app:layout_constraintEnd_toEndOf= parent app:layout_constraintStart_toStartOf= parent app:layout_constraintTop_toBottomOf= @+id/etPwd /
/android.support.constraint.ConstraintLayout
安卓端java代碼實(shí)現(xiàn)
html' target='_blank'>public class MainActivity extends AppCompatActivity { String loginUrl = http://soyoyo.esy.es/login.php  EditText etName; EditText etPwd; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); etName = findViewById(R.id.etName); etPwd = findViewById(R.id.etPwd); // 點(diǎn)擊button后執(zhí)行 public void doLogin(View view){ login(etName.getText().toString(),etPwd.getText().toString()); private void login(String name,String pwd){ EasyHttp.post(loginUrl) .baseUrl(url) .params( loginName ,name) .params( loginPwd , pwd) .execute(new CallBack String () { @Override public void onStart() { System.out.println( ------onStart------  @Override public void onCompleted() { System.out.println( ------onCompleted------  @Override public void onError(ApiException e) { e.printStackTrace(); @Override public void onSuccess(String s) { System.out.println( ------onSuccess------ + s); Toast.makeText(MainActivity.this,s,Toast.LENGTH_SHORT).show();}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請(qǐng)關(guān)注PHP !

相關(guān)推薦:

php如何實(shí)現(xiàn)隨機(jī)數(shù)字和字母驗(yàn)證碼的代碼

php技巧之如何巧妙避免PHP程序中的一些壞代碼

以上就是android和PHP實(shí)現(xiàn)簡(jiǎn)單的登錄的詳細(xì)內(nèi)容,PHP教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 镇康县| 大名县| 田阳县| 神池县| 无为县| 富裕县| 平昌县| 威宁| 思南县| 鄂托克前旗| 图们市| 新野县| 旅游| 高清| 龙门县| 普陀区| 静宁县| 惠州市| 怀来县| 江安县| 呼和浩特市| 手游| 淳安县| 盐池县| 朝阳县| 巴林右旗| 武鸣县| 朝阳区| 石河子市| 德州市| 宁都县| 太湖县| 泉州市| 漠河县| 大理市| 樟树市| 福海县| 海兴县| 乌兰察布市| 仪陇县| 平利县|