How to accept input from user in php and javascript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to accept input from user in php and javascript?

13th Apr 2019, 4:38 AM
Rahul Mahtolia
Rahul Mahtolia - avatar
3 Answers
+ 4
In javaScript: prompt(); In PHP: fgets(STDN);
13th Apr 2019, 5:12 AM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 2
PHP is server-side lang while js is a client side. PHP handle content passed to the server while js deals with dom object on the client side there is no significance of taking inputs from the user. There are still methods to take input In PHP : readline() Php manual : https://www.php.net/manual/en/function.readline.php In js: prompt() W3: https://www.w3schools.com/jsref/met_win_prompt.asp Rather than using this why don't you use an HTML form to take input and then handle it with PHP or js?
13th Apr 2019, 5:03 AM
Yugabdh
Yugabdh - avatar
0
I'm not sure creating input from JavaScript is the most effective way to do it, but you can create and input element using JavaScript: document.createElement("input") With PHP you can write HTML, so just make an input the normal way: <input />
13th Apr 2019, 5:06 AM
Zeke Williams
Zeke Williams - avatar