Hi Guys,
Im having difficulty setting up a simple login view.
this is my login method:
this is the php file i use to connect to the database:
I have tried a few different methods but don't seem to get anywhere. ANy help would be appreciated.
Dman.
Im having difficulty setting up a simple login view.
this is my login method:
Code:
-(IBAction)login:(id)sender{
NSString *myURL = [ NSString stringWithFormat: @"http://www.durimmanaj.co.uk/phpconnect2.php?userID=%@&password=%@", usernameField.text, passwordField.text];
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString:myURL]];
NSString *Str = [[NSString alloc] initWithBytes: [data bytes] length:[data length] encoding: NSUTF8StringEncoding];
if([Str isEqualToString:@"Wrong password"]){
NSLog(@"LOGIN INCORRECT");}
else {
NSLog(@"Login SUCCESS !!!");}
}
this is the php file i use to connect to the database:
PHP:
<?php
require("phpconnect.php");
$con=mysql_connect($server,$usr,$pwd);
$db=mysql_select_db($db,$con);
$user=mysql_real_escape_string($_GET["userID"]);
$password=mysql_real_escape_string($_GET["password"]);
$checkPwdQuery=mysql_query("SELECT password FROM users WHERE user='$user'");
$storedPwd=mysql_fetch_row($checkPwdQuery);
if ($password==$storedPwd[0]){
die ('Password match');}
else{
die ('Wrong password');}
?>
I have tried a few different methods but don't seem to get anywhere. ANy help would be appreciated.
Dman.
Last edited: