Wednesday, August 26, 2015

How to Create an HTML Input Box and Output to Another Page


Open the HTML source code page into which you desire to place the form containing a 'textarea' input box. In this example, you will be using 'sometext.html' as the HTML source page. The separate page with PHP code will be called 'displaysometext.php.' Both pages will be stored on the Web hosting server where your website is located.
Create the form section within the HTML source code, and tell the form that the data entered by the user will be submitted to the external PHP-enabled page. In the case of this example, the user data will be submitted to displaysometext.php. Enter the following line between the
and the
tags of the HTML page.Save the document to your computer as sometext.html and upload it to your Web hosting server.
Open a new page in your text editor and enter the following six lines of text.
Display Some Text PHP Script Page
?>
Save the page as displaysometext.php
Enter the following lines between the '
' lines that tells PHP to accept the text from the input box of the origination page. Remember that the name of the submit operation was 'comment.' When the user submits the form, that label will be submitted as the identifier for the text the user entered. The lines to accept this information should appear as follows.if(isset($_POST['submit'])){
$usercomments = $_POST['comment'];'
Have your PHP script do something with the text the user entered. This can be something as simple as printing to the Web browser what the user entered on the original page. In this example, type the following three lines.echo 'The information you entered was as follows:';
echo $usercomments;
}
Save the 'displaysometext.php' page code to your computer, then upload it into the same directory of the Web hosting server that contains HTML page containing the input box.
Point your browser to the HTML page that accepts the user input. That page, in this example, would be 'sometext.html'. Enter some text into the input box, then click the 'Submit Comments' button below it. Note that the small PHP code snippet in the 'displaysometext.php' page processes and displays everything you entered on a new Web page.
VPS Hosting

No comments:

Post a Comment