User input in php
1/15/2018 4:26:33 AM
Bhawna Sharma
1 Answer
New AnswerYou cannot take user input directly from PHP, as it is used for taking information from HTML. To take user input from HTML, you should start off by creating a form with an input field and a submit button: <form action = "code.php" method = "post"> <input type = "text" name = "words"> <input type = "submit"> </form> The method attribute specifies how the form should be submitted, post making it more secure, and the action attribute specifies where the information should be sent to. Then, in the PHP, you can get the information sent by the form by adding the $_POST superglobal array followed by the name of the input in square brackets: <?php echo $_POST["words"] ?> I hope this was helpful! d: