- PHP 100%
| .gitignore | ||
| FormApplication.php | ||
| LICENSE | ||
| PHPApplikation.php | ||
| README.md | ||
PHP Application
A PHP CRUD system that gives an admin control over the database: adding, removing, updating and viewing all agents and incidents, or a single one.
Requirements
- The site uses a request/response format (a form page and a response page).
- All data comes from the MySQL database.
- One page has a column layout.
- One page has a dropdown, a sökning (search) and a länk (link).
- The system has insert, update and delete functions.
Structure
The application has two main files:
form: the form page, where the admin enters input.PHPApplikation.php(app): the response page. The form submits to it with POST, and it runs the queries and prints the results.
Form
form is mostly HTML. PHP is used only to connect to MySQL and fill the dropdown with agents. It has four components:
textBox
Lets the admin look up one incident (by incident number) or one agent (by agent number). Each field is optional.
DisplayAllButtons
Two buttons, Display All Agents and Display All Incidents, which give an overview of everything in each table.
Sökning
A dropdown listing every agent by name, for when the admin doesn't know the agent number. Selecting a name and pressing Send shows that agent.
This section also holds the lön (salary) update. Select an agent in the dropdown, type the new lön in the field and submit.
addAgent
A form with four fields (nr, name, lön, uname) for adding a new agent, for example when someone is hired.
App
app has four parts. Each one only runs when the matching POST value is present.
Remove user
Deletes the agent's rows from Agent_LifsStill first (the dependent rows), then deletes the agent from Agent. It is triggered by the remove button on each row in Display All Agents, which sends the agent's nr.
Standard lookup
- Incident:
SELECTonIncidentbyIncident_Nr. - Agent: calls the stored procedure
GetAgentInfo. This is used by the text box and the dropdown. - Lön update: if a new lön was entered, calls the stored procedure
SetLönfirst, then shows the updated agent.
Display all
Prints either all incidents (ordered by Incident_Nr) or all agents (ordered by nr), each as a table. The agent view also includes the remove button for each agent.
Add user
Checks that no agent with the same nr exists. If one does, it shows an error. Otherwise it calls the stored procedure AddUser and confirms that the agent was added.
Database
Stored procedures used: GetAgentInfo, SetLön, AddUser.
Tables used: Agent, Agent_LifsStill, Incident.