Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. if(isset($_POST)){
  2.  
  3. $username = $_POST["username"];
  4. $email = $_POST["email"];
  5. $password = $_POST["password"];
  6.  
  7. $sql = 'insert into users(username, email, password) values("' . $username . '", "' . $email . '", "' . $password . '")';
  8.  
  9. if($conn->query($sql) === true){
  10. $output = "Inserted " . $username;
  11.  
  12. echo json_encode($output);
  13. } else{
  14. echo json_encode("Error: " . $conn->error);
  15. }
  16.  
  17. }
  18.  
  19. writeTable(u, e, p) : Promise<any>{
  20.  
  21. let url = "http://localhost/gameon-server-side/create.php";
  22.  
  23. let param = { username: u, email: e, password: p};
  24.  
  25. let request = this.http.post(url, param);
  26.  
  27. return request.toPromise();
  28.  
  29. <ion-row>
  30. <ion-col text-center>
  31.  
  32. <p>Response:</p>
  33. <p>{{responseTxt}}</p>
  34.  
  35. <button ion-button (click)="showTable()"> Read from table </button>
  36.  
  37. <ion-input class="txt" type="text" placeholder="Enter Username" [(ngModel)]="userName"></ion-input>
  38. <ion-input class="txt" type="text" placeholder="Enter Email" [(ngModel)]="userEmail"></ion-input>
  39. <ion-input class="txt" type="text" placeholder="Enter Password" [(ngModel)]="userPassword"></ion-input>
  40.  
  41. <button ion-button (click)="addTable(userName, userEmail, userPassword)"> Insert </button>
  42. <button ion-button> Update </button>
  43. <button ion-button> Delete </button>
  44.  
  45. </ion-col>
  46. </ion-row>
  47.  
  48. addTable(u, e, p){
  49. this.network.writeTable(u, e, p)
  50. .then(data => {
  51. console.log("I received: " + JSON.stringify(data));
  52. this.responseTxt = ""+ JSON.stringify(data);
  53. })
  54. .catch(e => {
  55. console.log(e);
Add Comment
Please, Sign In to add comment