PHP Forms (Practice Coding) | Learning PHP 2023

Pubblicato il: 11 marzo 2023
sul canale di: RaymondT
279
4

Hi guys! Welcome to my channel RaymondT.

GET vs. POST
Both GET and POST create an array. This array holds key/value pairs, where keys are the names of the form controls and values are the input data from the user.
Both GET and POST are treated as $_GET and $_POST. These are superglobals, which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special.

When to use GET?
Information sent from a form with the GET method is visible to everyone (all variable names and values are displayed in the URL).
GET also has limits on the amount of information to send. The limitation is about 2000 characters. However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases.
GET may be used for sending non-sensitive data.
Note: GET should NEVER be used for sending passwords or other sensitive information!

When to use POST?
Information sent from a form with the POST method is invisible to others (all names/values are embedded within the body of the HTTP request) and has no limits on the amount of information to send.
POST supports advanced functionality such as support for multi-part binary input while uploading files to the server.

PHP Form Validation
To protect data from hackers and spammers a secure validation must be done. You should validate every user input before processing.
Things to consider in validating form-data:
1. Validate the request method
2. Prevent Cross-Site Scripting (XSS) attacks
3. Remove unnecessary white spaces
4. Validate required input fields
5. Should only contain letters, numbers, and white spaces
6. Should be a valid email
7. Should be longer than 6 characters
8. Should be a valid URL

PHP Form Sticky
Sticky inputs are auto-filling inputs after submitting.
If the user forgot to fill in the email, an error message was shown. Also, all other inputs were cleared.
Sticky inputs prevent this annoying mistake.
To do this, the form and handler should be on the same script. We need to echo the submitted name and email as the value attribute of the input fields.


Just keep practicing and never stop learning.
Thank you for watching.


In questa pagina del sito puoi guardare il video online PHP Forms (Practice Coding) | Learning PHP 2023 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato RaymondT 11 marzo 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 279 volte e gli è piaciuto 4 spettatori. Buona visione!