php - Echo is not showing up in api -
i'm trying make api ios application sending post http requests
api.php
. i'm testing right now, echo not showing up? moment echo works when delete , write echo 'test';
.
here code:
<?php $user = ''; $pass = ''; $dbh = new pdo('mysql:host=localhost;dbname=ios', $user, $pass); if(isset($_post['status']) && $_post['status'] == "login")){ // login stuff }else if(isset($_post['status']) && $_post['status'] == "registreren")){ //register stuff if (isset($_post['username']) && isset($_post['password']) && isset($_post['email']))){ $username = $_post['username']; $email = $_post['email']; $password = $_post['password']; $sql = "insert `user` (username, password, email) values ('$username', '$password', '$email')"; if($dbh->execute($sql)){ echo 'did it'; }else{ echo 'nop'; } } }else{ echo 'something wrong'; } $dbh = null; // pdo sluiten ?>
i'm not @ php, in case there should return 'something wrong'
when accessing api.php
url because don't send post requests
it.
there several syntax errors might prevent code executing correctly. in every if-statement, there additional bracket.
eg: if(isset($_post['status']) && $_post['status'] == "registreren"))
should replaced if(isset($_post['status']) && $_post['status'] == "registreren")
(note last bracket missing).
remove additional brackets @ end of every if-statement in code , might fine.
Comments
Post a Comment