php - Get a specific user data from MySQL in Xcode -
my code working fine, getting information need, have write email user want information in php file. want information user write email in text field. how can that?
here php file:
<?php $servername = "*****"; $username = "*****"; $password = "*****"; $dbname = "*****"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } //i want email information xcode text field $sql = "select id, nome, email, cpf, senha usuario_log email = 'albino@peggou.com.br'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $resultado = array("status" => "0", "id" => $row["id"], "nome" => $row["nome"], "email" => $row["email"], "cpf" => $row["cpf"], "senha" => $row["senha"]); } } else { echo "0 results"; } echo json_encode($resultado); $conn->close(); ?>
here .m file, information displayed in log.
nsstring *urlstring = [nsstring stringwithformat: @"http://peggou.com.br/dados.php"]; nsurl *url = [nsurl urlwithstring:urlstring]; nsdata *data = [nsdata datawithcontentsofurl:url]; nsdictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; nsstring *statususer = [json objectforkey:@"status"]; nsstring *iduser = [json objectforkey:@"id"]; nsstring *nomeuser = [json objectforkey:@"nome"]; nsstring *emailuser = [json objectforkey:@"email"]; nsstring *cpfuser = [json objectforkey:@"cpf"]; nsstring *senhauser = [json objectforkey:@"senha"]; nslog(@"\n status: %@,\n id: %@,\n nome: %@,\n e-mail: %@,\n cpf: %@,\n senha: %@ \n", statususer, iduser, nomeuser, emailuser, cpfuser, senhauser);
Comments
Post a Comment