How to display the input from the textfield
To display the input from a textfield in PHP, we need 2 files. The first is a file for input and the second is a file that displays the results. For input files, simply with an html file, which contains a form, textfield, and the submit button. Meanwhile, the second file contains only the code to display the results.
Here is the first file that is named input.htm
<html>
<head><title> Input Form</title>
</head>
<body>
<FORM METHOD=POST ACTION=”result.php”>
Type Your Name : <INPUT TYPE=”text” NAME=”Name”><br />
<INPUT TYPE=”submit” value=”Submit”>
</FORM>
</body>
</html>
Explanation:
In the code above, note on the form tag, there is the form tag action with the property that points to a file named result.php. That means that the data contained in the textfield, will be sent to the file result.php. Next we will create the second file, namely result.php.
<?php
echo ‘Hello ‘.$_POST['Name'].’<br /> Glad to see you<br />’;
?>
<a href=”input.htm”>Return</a>
Explanation:
Take a look at $ _POST ['Name']. Same with the property name of the textfield in input.htm file. So the name of textfield in input.htm files, will be transformed into a variable in the file result.php. So that its contents will be displayed.
Incoming search terms for the article:
- display php result on textfield
- displaying file to jTextField
- format textField php
- input when displaying
- php text field display output
- print data in a text field php
Related posts: