5
05/11/2024 5:29 am
Topic starter
I need to create one HTML form for data submission + print "Hello, Person!"
The person MUST be from the user's input!
2 Answers
4
05/11/2024 5:30 am
Here's the solution: note line #8 - because you always MUST use htmlspecialchars for checking users' input!
<!DOCTYPE html> <html> <head> <title>Input Form</title> </head> <body> <?php if (isset($_GET['person'])) { $person = htmlspecialchars($_GET['person']); echo "Hello, $person!"; } else { ?> <form> Name: <input type="text" name="person"/><br> <input type="submit"> </form> <?php } ?> </body> </html>
1
05/11/2024 5:31 am
You can also see my solution:
<!DOCTYPE html> <html> <head> <title>Input Form</title> </head> <body> <form> <div>Name:</div> <input type="text" name="personName"/> <div>Age:</div> <input type="number" name="age"/> <div>Town:</div> <select name="townId"> <option value="10">Sofia</option> <option value="20">Varna</option> <option value="30">Plovdid</option> </select> <div><input type="submit"/></div> </form> <?php var_dump($_GET); ?> </body> </html>