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
663 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,680 points

Related Questions In PHP

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
4,243 views
0 votes
1 answer

How can I handle the warning of file_get_contents() function in PHP?

Hello @kartik, This is fairly simple: if (!$data = ...READ MORE

answered Apr 7, 2020 in PHP by Niroj
• 82,680 points
6,039 views
0 votes
0 answers

What are the differences in die() and exit() in PHP?

I think both have the same functionality, ...READ MORE

Apr 8, 2020 in PHP by kartik
• 37,510 points
218 views
0 votes
1 answer

What is the best way to allow plugins for a PHP application?

Hello @kartik, I've used, it's an attempt to ...READ MORE

answered Apr 15, 2020 in PHP by Niroj
• 82,680 points
173 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,680 points
13,162 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,680 points
1,610 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
333 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,680 points
185 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,680 points
3,078 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,680 points
1,239 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP