Php 如何在mysql的标签中显示用户数据?xcode
我正在开发一个应用程序,连接到mysql数据库,并使用用户和密码登录,这是伟大的工作,现在我需要从这个用户获得其他数据,并显示在标签中。如何从表中的该用户处获取这些数据并将其显示在标签中 我的PHP文件:Php 如何在mysql的标签中显示用户数据?xcode,php,mysql,login,Php,Mysql,Login,我正在开发一个应用程序,连接到mysql数据库,并使用用户和密码登录,这是伟大的工作,现在我需要从这个用户获得其他数据,并显示在标签中。如何从表中的该用户处获取这些数据并将其显示在标签中 我的PHP文件: <?php // Ghalia ALrajban // 21 Dec 2011 if (isset($_GET["email"]) && isset($_GET["senha"]) ){ $email = $_GET["email"];
<?php
// Ghalia ALrajban
// 21 Dec 2011
if (isset($_GET["email"]) && isset($_GET["senha"]) ){
$email = $_GET["email"];
$senha = $_GET["senha"];
$result = login( $email, $senha);
echo $result;
}
function makeSqlConnection()
{
$DB_HostName = "***.com";
$DB_Name = "***gou";
$DB_User = "***gou";
$DB_Pass = "***";
$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error());
mysql_select_db($DB_Name,$con) or die(mysql_error());
return $con;
}
function disconnectSqlConnection($con)
{
mysql_close($con);
}
function login($email, $senha)
{
//require (FILE);
$con = makeSqlConnection();
$sql = "select * from usuario_log where email = '$email' and senha = '$senha';";
$res = mysql_query($sql,$con) or die(mysql_error());
$res1 = mysql_num_rows($res);
disconnectSqlConnection($con);
if ($res1 != 0) {
return 1;
}else{
return 0;
}// end else
}// end of Function
?>
您可以使用
dataWithContentsOfURL
,并返回一个json结构,如顶部答案所述:
用于将其转换回ios部分
但请记住,试图一次显示>100个表行是不好的,因此请使用分页(SQL:
limit PN*PS+1,PS
,其中PN=页码,PS=页面大小),以确保您自己的理智。好的,这很可怕,您希望删除表吗
#pragma mark - BOTAO LOGIN
- (IBAction)loginButton:(id)sender {
// Verificar e informar se os dados estao em branco.
if([emailTextField.text isEqualToString:@""] || [senhaTextField.text isEqualToString:@""]) {
UIAlertView *errorbranco = [[UIAlertView alloc] initWithTitle:@"Erro" message:@"Preencha todos os campos" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[errorbranco show];
}
//Verificar informacoes no banco de dados
else{
NSString *strURL = [NSString stringWithFormat:@"http://peggou.com.br/login.php?email=%@&senha=%@", emailTextField.text, senhaTextField.text];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
//Informacoes Corretas
if ([strResult isEqualToString:@"1"]) {
[self performSegueWithIdentifier:@"entrou" sender:self];
}
//Informacoes Incorretas
else{
UIAlertView *error = [[UIAlertView alloc] initWithTitle:@"Erro" message:@"e-mail ou senha invalidos" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[error show];
}
}
}