Pass data to database


#1

hey Hi guys I want to add data to data base so this is my code in ts

constructor(public navCtrl: NavController,
public http: Http,
public NP: NavParams,
public fb: FormBuilder,
public toastCtrl: ToastController) {
this.baseURI = "src/app/";

}

register() {

let body: string = "key=create&name=" + this.name + "&email=" + this.email + "&number=" + this.number + "&password=" + this.password,
  type: string = "application/x-www-form-urlencoded; charset=UTF-8",
  headers: any = new Headers({ 'Content-Type': type }),
  options: any = new RequestOptions({ headers: headers }),
  url: any = this.baseURI + "add-data.php";
}

but above its showing me an error of POST http://localhost:8100/src/app/add-data.php 404 (Not Found)

Please help me to fix this issue in my app folder i have made php file to connect with database and store the data


#2

Your PHP script has to run on some kind of webserver, it can’t be part of your Ionic app.