AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

PHP GET and POST to store data on server


<< Previous Page
PHP tutorial
Next Page >>
PHP tutorial

PHP Tutorial » PHP GET and POST to store data on server

What is $_ GET and $_ POST in PHP?

In this lesson, we'll show you how to send data to the server and store using GET and POST methods.

Both methods transmit the information to the server differently, and each of them has different advantages and disadvantages, as described below.

PHP $_GET is a PHP super global variable used to collect data from a HTML form after submitting an HTML form with method="get".

$_GET can collect data sent in the URL.

PHP $_POST is a PHP super global variable used to collect data form a HTML form after submitting an HTML form with method="post".

$_POST is widely used to pass variables.

 

The $_GET Method

Information sent from an HTML form using $_GET method it is visible to everyone in browser's address bar, what means that all the variable names and their values will be displayed in the URL

For a better understanding we present an example:

Example (this is HTML - PHP editor, change text, values on this window)
<?php
if( $_GET["name"] || $_GET["email"] ) {
echo "Welcome ". $_GET['name']. ". <br />";
echo "Your email is ". $_GET['email']. " .";

exit();
}
?>
<html>
<body>

<form action = "<?php $_PHP_SELF ?>" method = "GET">
<p> Name: <input type = "text" name = "name" /></p>
<p>Age: <input type = "text" name = "email" /></p>
<input type = "submit" />
</form>

</body>
</html>

Related subjects:
PHP Function PHP $_GET and $_POST PHP Array

 

Tags: PHP GET and POST to store data on server,
PHP GET and POST method diference, on same page, same time, variables, together, php form get and post,
What is difference between GET and POST in PHP?
What is $_ GET and $_ POST in PHP?
What is $_ POST and $_ GET?
What is diff between GET and POST method?

php post
php get url
php get all post data
php get request
php post to url
get and post method difference
get and post method in html examples

 

The $_POST Method

The $_POST method transfers information data via HTTP headers. The information is encoded.

The example below shows a form with an input field and a submit button.

When a user submits the data by clicking on "Submit", the form data is sent to the file specified in the action attribute of the <form> tag

Example (this is HTML - PHP editor, change text on this window)
<?php
if( $_POST["name"] || $_POST["age"] ) {
if (preg_match("/[^A-Za-z'-]/",$_POST['name'] )) {
die ("invalid name and name should be alpha");
}
echo "Welcome ". $_POST['name']. "<br />";
echo "Your email ". $_POST['email']. ".";

exit();
}
?>
<html>
<body>

<form action = "<?php $_PHP_SELF ?>" method = "POST">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "email" />
<input type = "submit" />
</form>

</body>
</html>

 

Advantages of POST method

Advantages of POST method

Disadvantages of POST Method

 



PHP GET and POST to store data on server,
PHP GET and POST method diference, on same page, same time, variables, together, php form get and post,
What is difference between GET and POST in PHP?
What is $_ GET and $_ POST in PHP?
What is $_ POST and $_ GET?
What is diff between GET and POST method?

php post
php get url
php get all post data
php get request
php post to url
get and post method difference
get and post method in html examples
PHP GET and POST to store data on server - php tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home
PHP Introduction
PHP Install
PHP Syntax
PHP Variables
PHP Echo and Print
PHP Data Types
PHP String Function
PHP Constants
PHP Operator Types
PHP If Else and Elseif
PHP Switch
PHP While Loops
PHP Loop For Do Foreach
PHP Array
Convert Array to String
PHP Function
PHP GET and POST
PHP Date/Time Functions
PHP Login
PHP Delete Element
PHP eregi_replace()
PHP mysql_query()
PHP Errors to Display
PHP Loop For Do Foreach

PHP forms
PHP Form Example
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Error: Unable to connect to MySQL. Debugging errno: 1045 Debugging error: Access denied for user 'u142985959_ager'@'localhost' (using password: YES)