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,510 points
2,818 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,880 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,010 points
453 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
9,668 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,050 points
333 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,420 points
352 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,880 points
21,917 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,880 points
6,840 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
939 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,880 points
668 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,880 points
11,434 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,880 points
2,959 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