我試圖通過PHP中使用MySQL創建爲iPad登錄頁面,但它不是在即使是在網頁沒有錯誤記錄,請看下面的代碼:使用PHP for iPhone創建登錄頁面?
//-(IBAction)homePage: (id)sender{
NSString *post =[NSString stringWithFormat:@"username=%@&password=%@",loginName.text, password.text];
NSString *hostStr = @"http://localhost/iddb.php";
hostStr = [hostStr stringByAppendingString:post];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
if([serverOutput isEqualToString:@"Yes"]){{
homepage *hvc = [[homepage alloc]initWithNibName: nil bundle: nil];
hvc.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:hvc animated: YES];}
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"success" message:@"You are authorized"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertsuccess show];
} else {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Fail" message:@"Invalid Access"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertsuccess show];
}
PHP代碼:
<?php
$username = $_GET['username'];
$password = $_GET['password'];
$check = "select username, password from login where username='$username' and password='$password'";
{
mysql_connect("localhost", "root","") or die();
mysql_select_db("dadsdb") or die (mysql_error());
}
$login = mysql_query($check) or die (mysql_error());
if (mysql_num_rows($login)==1) {
$row = mysql_fetch_assoc($login);
echo 'yes';
exit;
} else {
echo 'No';
exit;
}
?>
請任何人可以建議我什麼地方出了錯
請編輯您的帖子並在其中添加PHP代碼。 –
該PHP代碼使我的頭髮站起來.... –
我從評論複製php代碼到問題的身體。我也相應地縮進了它。應該很明顯,提供的代碼有語法錯誤,因爲{和}大括號不應該是。 –