Akash Elhance
Akash Elhance

Reputation: 304

PHP code is converted as comments in browser and $_REQUEST is not displaying any data?

I have created two simple web pages, one is written in HTML, and the second is written in PHP. In the HTML page, I include form tag with action attribute and its attribute value is index.php(second page) and index.php(second page) include $_REQUEST but no value is displayed.

html page

<html>
<head>
<title>testing of php</title>
</head>
<body>
<h3>here the value will be displayed</h3>
<form method="post" action="index.php">
please enter your name:
<input type="text" name="don"></input><br>
<input type="button" value="send"></input>
</form></body>
</html>

php page

<html>
<head>
<title>testing of php</title>
</head>
<body>
<?php

echo "hello:";
echo $_REQUEST['don'];
?>
</body>
</html>

Upvotes: 0

Views: 67

Answers (2)

Malek Zarkouna
Malek Zarkouna

Reputation: 988

The type should be submit not button to submit the form using post method :

<input type="submit" value="send"></input>

Upvotes: 2

Oleg
Oleg

Reputation: 109

You need to make another input type. Working code:

HTML

<html>
<head>
<title>testing of php</title>
</head>
<body>
<h3>here the value will be displayed</h3>
<form method="post" action="index.php">
please enter your name:
<input type="text" name="don"></input><br>
<input type="submit" value="send"></input>
</form></body>
</html>

PHP

<html>
<head>
<title>testing of php</title>
</head>
<body>
<?php

echo "hello:";
echo $_REQUEST['don'];
?>
</body>
</html>

https://www.w3schools.com/html/html_form_input_types.asp https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit

Upvotes: 0

Related Questions