I am new to PHP as you may be able to tell from the question.
What I have is an iOS application that accesses a database 开发者_StackOverflow中文版via an apache server using a php front end. I have managed to get a user inserted into the database using a POST on a php script called NewUser.phpThe thing I am struggling with is how to organize the files and whether or not I need multiple php scripts for each query I want to run on the database or I am able to handle each different POST request in the same script?
As I said I am new to the concept of PHP. If anyone could point me in the right direction to maybe a tutorial or give me some pointers on here that would be great!
Disco
yes, you can handle more type of POST requests in one script.
For example script name is action.php and inside is code:
switch ($_POST['action']) {
case 'insert_user':
// code for inserting new user
break;
case 'delete_user':
// code for deleteing user
break;
// and so on ...
}
and when are you doing POST request you will have to add parameter action
which one will indetify the correct action.
POST /action.php HTTP/1.1
Some headers
action=insert_user&name=John&surname=Doe....
精彩评论