- 1

User input in php

How can I take user input in php code

15th Jan 2018, 4:26 AM
Bhawna Sharma
Bhawna Sharma - avatar
2 odpowiedzi
+ 2
You 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:
15th Jan 2018, 4:44 AM
Faisal
Faisal - avatar
0
Sure
4th Dec 2022, 3:07 PM
Alan Ambrose