That depends on the app and the issuer.
Definitely just have a link to auto authenticate the account. Will be pretty easy with php. Is your database MYSQL?
-(BOOL)isNetworkAvailable {
char *hostname;
struct hostent *hostinfo;
hostname = "microsoft.com";
hostinfo = gethostbyname (hostname);
if (hostinfo == NULL) {
return NO;
} else {
return YES;
}
}
First step;
check the user has an internet connection either wifi or network. (otherwise your app with crash)
Use a reliable host such as microsoft who're a little more worldwide friendly than google etc..
snippet
Code:-(BOOL)isNetworkAvailable { char *hostname; struct hostent *hostinfo; hostname = "microsoft.com"; hostinfo = gethostbyname (hostname); if (hostinfo == NULL) { return NO; } else { return YES; } }
Second Step
make the app POST information to your php script
Username, email, whatever else and some sort of security key
I used an NSMutableURLRequest to post mine in an app, it's quite simple. Then just log the response for either a success or an error.
Third Step
Create your .php file and have it error handle the $_POST, Then use PDO to connect to your database and insert the information, then provide an echo for your success/error message that will be logged in your app.
I also wouldn't recommend using mysql queries, as they're outdated and probably won't continue to be supported. They're also very prone to injections and flooring your database. Make sure you use PDO, it's not hard to learn and the best way to learn.
A simple bindValue into your query will save a lot of headache in the future.
EDIT: Also, to send the email.. You will just use the $_POST information to send a simple email from your server. This will be the easy part.
// Following 3 lines in viewDidLoad
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkEstablished:) name:kReachabilityChangedNotification object:nil];
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
- (BOOL)networkEstablished:(NSNotification *)notification
{
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus == NotReachable) { return false };
return true;
}
if(remoteHostStatus == ReachableViaWiFiNetwork)
NSLog(@"Wifi connection established");
if(remoteHostStatus == ReachableViaCarrierDataNetwork)
NSLog(@"Carrier Data connection established");
<?php
$user = '***';
$pass = '***';
$db_loc = '***';
$db_name '***';
$db = new PDO('mysql:host=$db_loc;dbname=$db_name', $user, $pass);
if (isset($_POST['submit']))
{
if ($_POST['security'] == '****')
{
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']) && isset($_POST['age']) && isset($_POST['location']) && isset($_POST['extra']) && isset($_POST['extra2']) && isset($_POST['extra3']))
{
$query = "INSERT INTO tableTitle(
username,password,email,age,location,extra,extra2,extra3) VALUES (
?,?,?,?,?,?,?,?)";
$stmt = $db->prepare($query);
$stmt->bindValue(1, $_POST['username']);
$stmt->bindValue(2, $_POST['password']);
$stmt->bindValue(3, $_POST['email']);
$stmt->bindValue(4, $_POST['age']);
$stmt->bindValue(5, $_POST['location']);
$stmt->bindValue(6, $_POST['extra']);
$stmt->bindValue(7, $_POST['extra2']);
$stmt->bindValue(8, $_POST['extra3']);
$worked = $stmt->execute();
if ($worked == true)
{
echo 'Submission Successful';
} else {
echo 'Database Connection Issue';
}
}
else
{
echo 'Not all components are complete, unable to submit request.';
}
}
else
{
echo 'Security Code Invalid.';
}
}
?>