How to submit a simple HTML form and access html input element using PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How to submit a simple HTML form and access html input element using PHP?

A cookie associated with a cross-site resource @http://solocode.azurewebsites.net/ was set without the "sameSite" attribute - it has been blocked as Chrome now only delivers cookies with cross-site requests if they are set with "sameSite=None" and "Secure"

17th Aug 2020, 5:35 AM
niteOwLTwOwHO
niteOwLTwOwHO - avatar
3 Answers
+ 2
If you have POST method on your form, then you access the value of each input after submit in PHP with $_POST['name_of_input_element'] for example: <?php if(isset($_POST['username'])){ echo $_POST['username'] ; } <form method="POST"> <input type="text" name="username"> <input type="submit"> </form>
17th Aug 2020, 8:49 AM
Jiří Zbořil (ZboraCZ)
Jiří Zbořil (ZboraCZ) - avatar
+ 2
Thanks for your response.. My question should have been why my submission cannot be set using either POST or GET methods.. When I look in the Chrome Developers Toolkit it says that my HTTP request was blocked due to cross-site request not set with "sameSite=None" and "Secure"..i'll make my code Public so you can see what I mean,, submit6.html and submit6.php
17th Aug 2020, 11:59 AM
niteOwLTwOwHO
niteOwLTwOwHO - avatar
0
Make sure you have your method set. Its GET by default if you dont specify it i think :D But are you sure you can access your two separate files? Like they can see each other? I am not sure about that. Try to put the whole HTML into the PHP file and try it then.
17th Aug 2020, 12:43 PM
Jiří Zbořil (ZboraCZ)
Jiří Zbořil (ZboraCZ) - avatar