Detri Amelia Chandra
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor
No Result
View All Result
Detriamelia.com
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor
No Result
View All Result
Detriamelia.com
No Result
View All Result

13. New Performing PHP Form Handling

13/02/2020
in PHP
PHP Form Handling

PHP Form Handling

Detriamelia.Com – Running form functions in PHP is not difficult. By using the $ _POST and $ _GET methods it becomes easier. Handling forms in PHP with this modern style requires a little knowledge of $ _GET and $ _POST. For that, don’t forget to first learn the concept of handling forms in PHP using these methods. The PHP superglobals $_GET and $_POST are used to collect form-data.

PHP – A Simple HTML Form

PHP Form Handling
PHP Form Handling

The model beneath shows a basic HTML structure with two info fields and a submit button:

1
2
3
4
5
6
7
8
9
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>

At the point when the client rounds out the structure above and taps the submit button, the structure information is sent for preparing to a PHP document named “welcome.php”. The structure information is sent with the HTTP POST strategy.
To show the submitted information you could essentially reverberate all the factors. The “welcome.php” resembles this:

1
2
3
4
5
6
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>

The output could be something like this:

1
2
Welcome John
Your email address is john.doe@example.com

The same result could also be achieved using the HTTP GET method:

1
2
3
4
5
6
7
8
9
<html>
<body>
<form action="welcome_get.php" method="get">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>

and “welcome_get.php” looks like this:

1
2
3
4
5
6
<html>
<body>
Welcome <?php echo $_GET["name"]; ?><br>
Your email address is: <?php echo $_GET["email"]; ?>
</body>
</html>

The code above is very straightforward. Notwithstanding, the most significant thing is absent. You have to approve structure information to shield your content from malignant code.

Think SECURITY when preparing PHP structures!

This page doesn’t contain any structure approval, it just shows how you can send and recover structure information. In any case, the following pages will tell the best way to process PHP structures in view of security! Legitimate approval of structure information is imperative to shield your structure from programmers and spammers!

$_GET vs $_POST

Both GET and POST make an exhibit (for example exhibit( key1 => value1, key2 => value2, key3 => value3, …)). This exhibit holds key/esteem sets, where keys are the names of the structure controls and qualities are the info information from the client.
Both GET and POST are treated as $_GET and $_POST. These are superglobals, which implies that they are constantly available, paying little heed to scope – and you can get to them from any capacity, class or record without doing anything exceptional.
$_GET is a variety of factors went to the present content by means of the URL parameters.
$_POST is a variety of factors went to the present content by means of the HTTP POST technique.

When to utilize GET?

Data sent from a structure with the GET strategy is noticeable to everybody (every single variable name and qualities are shown in the URL). GET additionally has confines on the measure of data to send. The impediment is around 2000 characters. Be that as it may, in light of the fact that the factors are shown in the URL, it is conceivable to bookmark the page. This can be valuable at times.
GET might be utilized for sending non-delicate information.
Note: GET ought to NEVER be utilized for sending passwords or other delicate data!

When to utilize POST?

Data sent from a structure with the POST strategy is imperceptible to other people (all names/values are inserted inside the body of the HTTP demand) and has no restrictions on the measure of data to send.
In addition POST underpins propelled usefulness, for example, support for multi-part parallel information while transferring documents to server.
Notwithstanding, in light of the fact that the factors are not shown in the URL, it is beyond the realm of imagination to bookmark the page.

Tags: PHP
ShareTweetShare

Related Posts

PHP Forms - Validation With Required Fields
PHP

14. PHP Forms – Validation With Required Fields

Hi everyone, this time we will discuss about PHP Validation using the Required Field. Not many people know, it turns...

15/02/2020
Learn PHP Global Variables - Superglobals With Example
PHP

12. Learn PHP Global Variables – Superglobals With Example

On this occasion, we will discuss Global and Superglobal Variables. These variables are some that are very important to implement....

20/01/2020
PHP Array Example, Complete Editions
PHP

11. PHP Array Example, Complete Editions

Welcome back to the PHP programming learning page. This time we will discuss arrays, more precisely arrays in PHP. Arrays...

17/01/2020
PHP Function Definition and Example
PHP

10. PHP Function Definition and Example

In this discussion, we will discuss about PHP Function. We really need PHP Function in certain circumstances when coding. The...

15/01/2020
Next Post
PHP Forms - Validation With Required Fields

14. PHP Forms - Validation With Required Fields

Web and Mobile Programming – Library Part-1

Web and Mobile Programming - Library Part-1

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

Prevent XSS Injection Attacks On PHP Easily

Prevent XSS Injection Attacks On PHP Easily

21/05/2019
Fungsi Peformatan Rupiah Pada Angka PHP

How to Make Rupiah Format Function for Number Using PHP

02/04/2019
install-apache-mysql-and-php-in-ubuntu-18-04-lts-part-2

2. How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1

11/11/2019
GIS Tutorial with Leafletjs (Popup and Marker Modifications)

GIS Tutorial with Leafletjs (Popup and Marker Modifications)

29/07/2019

Instagram Feed

    The Instagram Access Token is expired, Go to the Customizer > JNews : Social, Like & View > Instagram Feed Setting, to refresh it.
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
Detriamelia.Com

© 2022 Detri Amelia Chandra - IT Tips and Programming Tutorials.

No Result
View All Result
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor