# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.readable_text
This chapter shows how to keep the values in the input fields when the user hits the submit button.

PHP - Keep The Values in The Form

To show the values in the input fields after the user hits the submit button, we add a little PHP script inside the value attribute of the following input fields: name, email, and website. In the comment textarea field, we put the script between the <textarea> and </textarea> tags. The little script outputs the value of the $name, $email, $website, and $comment variables.

Then, we also need to show which radio button that was checked. For this, we must manipulate the checked attribute (not the value attribute for radio buttons):

Name: <input type="text" name="name" value="<?php echo $name;?>">

E-mail: <input type="text" name="email" value="<?php echo $email;?>">

Website: <input type="text" name="website" value="<?php echo $website;?>">

Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>

PHP - Complete Form Example

Here is the complete code for the PHP Form Validation Example:

# data[].attributes.attachment_link.description
This chapter shows how to keep the values in the input fields when the user hits the submit button. To show the values in the input fields after the user hits the submit button, we add a little PHP script inside the value attribute of the following input fields: name, email, and website.

# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.description
Edpuzzle video lesson. Make any video your lesson. Take a video and crop it, add your voice or embed questions at any point.

# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.readable_text
The PHP superglobals $_GET and $_POST are used to collect form-data.

PHP - A Simple HTML Form

The example below displays a simple HTML form with two input fields and a submit button:

When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named "welcome.php". The form data is sent with the HTTP POST method.

To display the submitted data you could simply echo all the variables.

The "welcome.php" looks like this:

<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:

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

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

Example

Same example, but the method is set to GET instead of POST:

Run Example "

and "welcome_get.php" looks like this:

<html> <body> Welcome <?php echo $_GET["name"]; ?><br> Your email address is: <?php echo $_GET["email"]; ?> </body> </html>

The code above is quite simple, and it does not include any validation.

You need to validate form data to protect your script from malicious code.
Think SECURITY when processing PHP forms!
This page does not contain any form validation, it just shows how you can send and retrieve form data.

However, the next pages will show how to process PHP forms with security in mind! Proper validation of form data is important to protect your form from hackers and spammers!

GET vs. POST

Both GET and POST create an array (e.g. array( key1 => value1, key2 => value2, key3 => value3, ...)). 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.

$_GET is an array of variables passed to the current script via the URL parameters.

$_POST is an array of variables passed to the current script via the HTTP POST method.

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.

Moreover POST supports advanced functionality such as support for multi-part binary input while uploading files to server.

However, because the variables are not displayed in the URL, it is not possible to bookmark the page.
Developers prefer POST for sending form data.
Next, lets see how we can process PHP forms the secure way!

PHP Exercises

# data[].attributes.attachment_link.description
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

# data[].attributes.attachment_link.description
Easily create beautiful interactive video lessons for your students you can integrate right into your LMS. Track students' progress with hassle-free analytics as you flip your classroom!

# data[].attributes.attachment_link.description
A collaborative platform for your conferences and your training sessions

# data[].attributes.attachment_link.description
A collaborative platform for your conferences and your training sessions

# data[].attributes.attachment_link.title
Selection simple by RAFED RAFED.ALBDR - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.attachment_link.title
Selection Multiple PHP by matheo gerdil - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.attachment_link.title
Resumé CheckBox by ADRIEN ADRIEN.SNTS - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.attachment_link.title
TextArea Input Text by SHACO SHACO.MHMD - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.attachment_link.title
Recupération RadiosButtons by SIMON SIMON.CDT - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.attachment_link.title
TextArea Input Text by SHACO SHACO.MHMD - AhaSlides

# data[].attributes.attachment_link.description
Join this live engagement platform and have your say! Interact with live polls, fun quizzes, Q&As, word clouds, brainstorms and more!

# data[].attributes.headline
Explication du Padlet de l'expérimentation

# data[].attributes.subject
Explication du Padlet de l'expérimentation

# data[].attributes.attachment_link.readable_text
Padlet explication

0:00

8:47

Back

# data[].attributes.attachment_link.readable_text
0:00 / 3:41•Watch full video

# data[].attributes.attachment_link.readable_text
0:00 / 6:13•Watch full video