How to get user input in PHP, and store it's value in a variable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to get user input in PHP, and store it's value in a variable?

18th Apr 2017, 3:43 AM
Silas Junior
Silas Junior - avatar
2 Answers
+ 2
you should creat an input field in form html and get the value from the $_get or $_post array. like this https://code.sololearn.com/w51NO7XRDTA5/?ref=app
18th Apr 2017, 5:12 PM
Elghozi Nasreddine
Elghozi Nasreddine - avatar
+ 1
create an input field of the type you want for example: <input type="text" name="xyz" > create the submit button: <input type="submit" name="sub" value="Submit"> now for storing user input in a variable: if(isset($_POST['sub'])) { $userinput=$_POST['xyz']; }
18th Apr 2017, 4:45 AM
Abhinav Singh
Abhinav Singh - avatar