Hi Robotwoods,
Thanks for the code.
For sending a Tweet, the "setHTTPBody" is just a single NSString for "status=%@".
For the example php code, how should I code the "setHTTPBody" in the iPhone program to POST into the fields e.g. "$username" and "$password"?
The following code is what I tried:
Code:
NSURL *phpURL=[NSURL URLWithString:@"http://(test web site)/iphoneupdate.php"];
NSMutableURLRequest *phpRequest=[[NSMutableURLRequest alloc] initWithURL:phpURL];
[phpRequest setHTTPMethod:@"POST"];
NSString *sendToPhp=[[NSString alloc] initWithFormat: @"username:%@, password:%@", sendUsername, sendPassword];
[phpRequest setHTTPBody:[sendToPhp dataUsingEncoding:NSASCIIStringEncoding]];
How to specify to POST "sendUsername" to the field "$username", and POST "sendPassword" to the field "$password"?
Thanks a lot!
Gary
Quote:
Originally Posted by RobotWoods
check out w3schools.com, it's a good resource for PHP.
you're going to end up doing something like (here assuming it's just username password):
PHP Code:
<?php
//
here would be your code to connect to the mysql server and db
//
//this takes items sent via POST and makes them easier to cite
$username=$_POST["username"];
$password=$_POST["password"];
//now just do whatever you need to do
$passwordCheck=mysql_query("SELECT password FROM userinfo WHERE username=$username";
$storedPassword=mysql_fetch_row($passwordCheck);
if($password==$storedPassword){
//something
}
else{
//something else
}
?>
|