This is a very simple question, and most likely requires a very simple answer. I am pulling data from a MYSQL database, and constructing a table using the retrieved data. I am constructing a CRUD table, having the last two columns being ‘edit’ and ‘delete’. The form I am constructing the final two columns will look something like this:
The following is found in Welcome.php:
<form action="delete.php" method="POST">
<input type="hidden" value="ptest"/>
<input type="submit" value="Sign Up"/>
</form>
However, should I make the form’s action call the current page instead?
<form action="welcome.php" method="POST">
<input type="hidden" value="ptest"/>
<input type="submit" value="Sign Up"/>
</form>
I’m very new to PHP and I want to ensure that I am following proper protocol. If this is more an opinion than anything else, please at least leave me your professional opinions.
Thank you very much,
Evan
You shouldn’t.
There is not a strict standard.
Being a newbie, you may find that separate file for the each action easier to understand. So, go for it.
With more experience you will find that having all actions in a single file makes the code shorter and more convenient.
What you have to have in a separate file – is a form itself.
So, you’ll be able to use the same form for adding new record, editing existing one and to show submit errors.
Here is an example of one-pager. It does not delete though but can give you a general idea.
It lets you add, edit and browse records.
the code
The templates
form.php
and list.php