Hi
I was created a database to register users contains (username, email ,password)and linked them with my app by json and php, user can register without any problem,
also i was created login page contains ( email ,password) when i trying to login it always gives me this message the email and password wrong but there is no error in the console.
this php login code
<?php
include "db.php";
$input2 = file_get_contents('php://input');
$data = json_decode($input2,true);
$email = $data['email'];
$pass = $data['pass'];
$sqll= "SELECT email, pass FROM userslist ";
$result = mysqli_query($connection,$sqll);
if(mysqli_num_rows($result)>0){
while ($row = mysqli_fetch_assoc($result)){
$response= "correct";
}
}
else {
$response= "0 results";
}//turn PHP into JSON with json_encode()
echo json_encode( $response);
?>
this json code
<?php
include "db.php";
$view2=array();
$qqq = mysqli_query($connection,"SELECT email, pass FROM `userslist`");
while ($row=mysqli_fetch_object($qqq)){
$view2 []=$row;
}
echo json_encode($view2);
echo mysqli_error($connection);
?>
this login.ts
import { Component , ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams ,ToastController ,AlertController } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { LoadingController } from'ionic-angular';
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class LoginPage {
@ViewChild("email") email;
@ViewChild("pass") pass;
data:any={};
constructor(public navCtrl: NavController, public navParams: NavParams ,
public http: Http, public toast: ToastController ,public loading: LoadingController , public alertCtrl: AlertController) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad LoginPage');
}
insertx(){
let data = {
email: this.email,
pass: this.pass
};
let loader = this.loading.create({
content: 'Processing please wait…',
});
loader.present().then(() => {
this.http.post('http://SignUp/loginphp2.php',this.data)
.map(view2 => view2.json())
.subscribe(view2 => {
console.log(view2)
loader.dismiss()
if(view2=="Your Login success"){
let alert = this.alertCtrl.create({
title:"CONGRATS",
subTitle:(view2),
buttons: ['OK']
});
alert.present();
}else
{
let alert = this.alertCtrl.create({
title:"ERROR",
subTitle:"Your Login Username or Password is invalid",
buttons: ['OK']
});
alert.present();
}
});
});
}
}
Do I have to create a log-in database and linked with register database? because I have one database it register database