Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

How to take input from the user's in PHP:-

To take input from the user's in PHP, We will Create HTML Form Element and get data from Text Filed, Button, etc.
We will use get and post method to send data from the form element to Variable.

HTML Provide complete forms and form elements to create a dynamic form using HTML.


Step by Step Implementation for USER INPUT OPERATION IN PHP:-


Step1st:-  Create AdditionDesign.php

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="AdditionLogic.php" method="post">
<input type="text" name="txtnum1" placeholder="Enter First Number" />
<br>
<br>
<input type="text" name="txtnum2" placeholder="Enter Second Number" />
<br>
<br>
<input type="submit" name="btnsubmit" value="Addition" />
</form>
</body>
</html>


Create AdditionLogic.php

<?php
$num1 = $_REQUEST['txtnum1'];  //$_REQUEST is the predefine variable which is used to get from element data
$num2 = $_REQUEST['txtnum2'];
$num3 = $num1+$num2;
echo $num3;
?>


Explanation of this program:-

1)  <form> :-  it is most important HTML Tag which will be used to create form


2) <input type="text"  /> :-  It is used to create textfield 


3)  <input type="submit" />  It is used to create submit button


4)  method= "post" and method="get":-  form has two different, method post and get, a post is most secure and reliable as compare to get.


5)  $_POST :-   Ir is called super global variable in PHP which is used to get data from the post method.


6)  $_GET:-  It is also called a super global variable in PHP which is used to get data from the GET method.


7)  $_REQUEST:-  It is also called a super global variable in PHP that is common for Get method and Post method both.



Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post