What is the use of REQUEST variable in php

0 votes
What is the use of  $_REQUEST variable in submitting the form?

thank you!
Mar 27, 2020 in PHP by kartik
• 37,520 points
3,288 views

1 answer to this question.

0 votes

Hii @kartik,

The $_REQUEST variable is used to read the data from the submitted HTML form.

Sample code:

Here, the $_REQUEST variable is used to read the submitted form field with the name ‘username’. If the form is submitted without any value, then it will print as “Name is empty”, otherwise it will print the submitted value.

<?php

if (isset($_POST['submit'])) {

// collect value of input field

$name = $_REQUEST['username'];

if (empty($name)) {

echo "Name is empty";

} else {

echo $name;

}

}

else

{

?>

<form method="post" action="#">

Name: <input type="text" name="username">

<input type="submit" name="submit">

</form>

<?php } ?>

Hope this is helpful

Thank you!

answered Mar 27, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
0 answers

What is meaning of tilde(~) symbol mean in the context of this PHP documentation page?

Please explain the significance of the tilde() ...READ MORE

Aug 5, 2022 in PHP by Kithuzzz
• 38,000 points
689 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,544 views
0 votes
0 answers

What's the use of ob_start() in php?

Is ob_start() used for output buffering so ...READ MORE

Jun 3, 2022 in PHP by Kichu
• 19,040 points
522 views
0 votes
0 answers

What does the variable $this mean in PHP?

Can someone please explain how the variable ...READ MORE

Jun 11, 2022 in PHP by narikkadan
• 63,600 points
561 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,021 views
0 votes
1 answer

What is type casting and type juggling in php?

Hey, The way by which PHP can assign ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
7,189 views
0 votes
2 answers

How can we create a session in PHP?

Hello, niroj. Here is my idea session_start(); $_SESSION['USERNAME'] ...READ MORE

answered Dec 7, 2020 in PHP by Famous
• 140 points
1,184 views
0 votes
1 answer

How to clone a JavaScript object?

Hello, You can clone an object and remove ...READ MORE

answered Apr 2, 2020 in Java-Script by Niroj
• 82,840 points
933 views
0 votes
1 answer

What is the use of the @ symbol in PHP?

Hello @kartik, The @ symbol is the error control operator ("silence" or "shut-up" ...READ MORE

answered Apr 9, 2020 in PHP by Niroj
• 82,840 points
12,029 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,840 points
3,268 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP