hi guy
I try to work on a login page that i would to save the username and password for next time on local storage (i use local-storage not SQL ) also i would that username and password send to a php file to authenticate the save it locally .
this how i needed :
username && password ==> send to php to auth ==> get the accept from php side ==> save this username and password into a local storage for the next login
I use an ionic 2 ts
this may code :
public username;
public password;
public data;
public dbUrl = 'http:/xxx/userLogin.php';
public promos: any;
public local : Storage ;
public us : any;
public ps : any;
constructor(public nav: NavController, private http: Http,public loginservice : FromService ) {
this.nav = nav;
this.http = http;
this.local = new Storage(LocalStorage);
this.local.set('username', 'true');
this.local.set('password','true');
}
store(username, password){
this.local.get('username' && 'password').then((result) => {
//here where i want to send it to php
if(//here where i want to send it to php ){
var us= this.local.set('username',JSON.stringify(username));
var ps= this.local.set('password',JSON.stringify(password));
this.nav.present(toast);
this.nav.push(HomePage)
} else {
this.local.set('username' && 'password', true);
this.nav.present(toast);
this.nav.push(LoginPage)
}
var data = JSON.stringify({username: this.username});
this.http.post(dbUrl,us ,ps)
.subscribe(data => {
this.data.response = data._body;
}, error => {
console.log("Oooops!");
});
});
}
any help please