Validating forms and links data
To show data that was sent from a link or form, we can use any of the methods we have already learned in previous chapters.
Validations in PHP
To show data that was sent from a link or form, we can use any of the methods we have already learned in previous chapters:
Leave prepared the HTML tags inside which we will insert with echo the received variables, or have PHP generate all the data of the variables as the HTML code that wraps them.
But, waiting for a user's data to show it below, has its risks. As the arrival of these data depends on the user, many times we will find the surprise that the expected data did not arrive; that is to say, nothing guarantees to us in an infallible way that the user has provided that data that we are waiting for to be used later in the assembly of a dynamic page that shows that data.
Therefore, it is extremely important that we learn to verify:
- That the data has reached the server
- They have been sent by the means we expect. That is, we verify its origin (that have been sent using the get method, or post, depending on the case),
- And that its value is valid (that is not empty, that it is the type of data that we expect, that it is within the range of values allowed, etc.)
For this very common task of verifying data before using them, conditionals are used, which is the topic that we will learn next.
ChatGPT Free
Ask questions on any topic
CITE ARTICLE
For homework, research, thesis, books, magazines, blogs or academic articles
APA Format Reference:
Delgado, Hugo. (2019).
Validating forms and links data.
Retrieved Nov 11, 2024, from
https://disenowebakus.net/en/validations-php