@Fares95 wrote:
Hello , i have an issure after i used api to connect my application with ionic
here my ts
addRgister(){ let body = { cin: this.cin , fullname: this.fullname , mailadress: this.mailadress , password: this.password, aksi: 'add_Register' } this.postPvdr.postData(body, 'file_aksi.php') .subscribe((data) => { var alertpesan = data.msg; if (data.success){ console.log ('register successful'); }else { console.log ('register failed'); } }); }
provider-ts :
addRgister(){ let body = { cin: this.cin , fullname: this.fullname , mailadress: this.mailadress , password: this.password, aksi: 'add_Register' } this.postPvdr.postData(body, 'file_aksi.php') .subscribe((data) => { var alertpesan = data.msg; if (data.success){ console.log ('register successful'); }else { console.log ('register failed'); } }); }
my files php :
config.php<?php define('DB_HOST','localhost'); define('DB_USER','root'); define('DB_PASSWORD', ''); define('DB_NAME','database-pfe'); $con = mysqli_connect( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); ?>
my file file_aksi.php
<?php header ('Access-Control-Allow-Origin: *'); header ("Access-Control-Allow-Credentials: true "); header ("Access-Control-Allow-Methods: POST, GET, OPTIONS"); header ("Access-Control-Allow-Headers: Content-Type , Authorisation , X-Requested-With"); header ("Content-Type: application.json; charset=utf-8"); include "config.php"; $postjson= json_decode(file_get_contents('php://input'), true); if($postjson['aksi']=="add_Register"){ $password= md5($postjson ['password']); $query= mysqli_query($mysqli, "INSERT INTO compte SET cin= $postjson ['cin'], password= $postjson ['password']), nom-prenom= $postjson ['fullname'], mailadress= $postjson ['mailadress'] "); if($query) { $result = json_encode(array('success' => true)); } else { $result = json_encode(array('success' => false , msg => 'erreur, svp essayer autre fois')); echo $result; } } ?>
Posts: 1
Participants: 1