Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在使用PHP和mysql数据库成功登录XCode后重定向到新视图_Php_Mysql_Ios - Fatal编程技术网

如何在使用PHP和mysql数据库成功登录XCode后重定向到新视图

如何在使用PHP和mysql数据库成功登录XCode后重定向到新视图,php,mysql,ios,Php,Mysql,Ios,我有一个项目,这是一个Ipad应用程序。我将Xcode用于PHP和mysql数据库 我有一个登录视图,它应该通过PHP检查数据库来验证用户的用户名和密码,然后它应该将用户移动到他的概要视图 在PHP中,我知道:ex.(header(“Location:profile.PHP”)语句会将用户移动到页面(profile.PHP) 我的问题是: 使用php和xcode从一个视图移动到另一个视图需要使用哪条语句, 而不是移动到php页面? 如何为我的登录代码创建会话 以下是我的PHP代码: <?p

我有一个项目,这是一个Ipad应用程序。我将Xcode用于PHP和mysql数据库

我有一个登录视图,它应该通过PHP检查数据库来验证用户的用户名和密码,然后它应该将用户移动到他的概要视图

在PHP中,我知道:ex.(header(“Location:profile.PHP”)语句会将用户移动到页面(profile.PHP)

我的问题是:

使用php和xcode从一个视图移动到另一个视图需要使用哪条语句, 而不是移动到php页面? 如何为我的登录代码创建会话

以下是我的PHP代码:

<?php

//Getting entered values
$username = $_GET['name'];
$password = $_GET['pass'];

//database info 
$DB_HostName = "localhost";
$DB_Name = "test";
$DB_User = "root";
$DB_Pass = "";
$DB_Table = "user";

//connecting to database
$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass);
mysql_select_db("$DB_Name");


//Create query
$qry="SELECT * FROM user WHERE name='$username' AND pass='$password' ";
$result=mysql_query($qry);



while($row= mysql_fetch_array($result)){

if($row['pass']== $password){
echo $row['name'];
}else{
echo'error';
}

?>
要从一个视图移动到另一个视图,我必须使用哪个语句 使用php和xcode,而不是移动到php页面

在目标C中,您可以通过执行从一个控制器到另一个控制器的顺序来读取函数

如何为我的登录代码创建会话

您可以从php中设置一个标志来确定登录是否有效。 如果经过身份验证,则可以使用存储所需的值。
该标志可以是从php脚本发送到iPad应用程序的布尔值。

您是否尝试使用从php返回的值?@Wain No。。如何在文本字段中查看从PHP文件中获取的数据?您已经在记录返回的文本。这样传递用户名和密码安全吗?NSMutableString*mtURL=[[NSMutableString alloc]initWithFormat:@”/login.PHP?name=%@&pass=%@,username.text,password.text]?有没有其他方法像我们提交php表单和POST一样?
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


- (void)enterCredential{

    NSMutableString *mtURL = [[NSMutableString alloc] initWithFormat:@"http://localhost     /login.php?name=%@&pass=%@",username.text ,password.text];


    [mtURL setString:[mtURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

    NSData * dataUrl = [NSData dataWithContentsOfURL:[NSURL URLWithString:mtURL]];
    NSMutableString * mtResult = [[NSMutableString alloc] initWithData:dataUrl encoding:NSUTF8StringEncoding];
    NSLog(@"PHP fatmah %@", mtResult);
}

@end