In your index.php file must have the following operations:
Can create or add a record (refer to the attribute of your table user for adding data). Then the data must be displayed in the table. Your table must contain all the attributes, with an UPDATE button to modify and a DELETE button to remove the data. Then submit the index.php file only.
CodePudding user response:
yes you can , but best practices are not writing all in one single file put each action in separate class and separate file refer to solid principle and single responsibility your class should has single responsible
CodePudding user response:
I understand your confusion. Most modern php applications work with a single index.php as the entry point of your application. Your webserver like for example nginx or apache is responsible of using your index.php as entry point from a variety of other endpoints. For example Laravel recommends this nginx config. This line is responsible:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
So when your webserver is configured right, it most certainly is possible to handle multiple requests from a single file. Of course later to make your code better you will use more files, which will be called from index.php as all code in a single file will become messy very soon.
CodePudding user response:
Have to answer here cause of lack of reputation..
So you have your form and in your single file to handle all request for C.R.U.D, you need to implement a logic to handle different requests.. Let's imagine a row which shows some data, for example -> Artist: Linkin Park, Album: Meteora. In the same row you also have create, read, update and delete buttons/icons. So depending on what the user selects, you send a request to your script that first checks which action the user choose with an if statement or switch for example. So the script gets into the right block and executes code to process user request.
edit: So you send your form data, the request always to one file and depending on the keyword in your Get or Post global variable, your script will execute the right block for processing.
