I am sorry if this is a repeating question, but I can’t find anyone who might have the same question as me yet. I am new in html and php, and I am trying to learn more by practising, basically creating a registration form and keep all the data in the MySQL database, by using xampp. I have created a registration form and saved it as a .html file format, but how can I use php to send the user input from html to the MySQL database? I have seen a lot of examples on Google, but most of them are using php file format, for example instead of registration.html, they use registration.php. I really do appreciate your help. Thank you very much StackOverflow community members.
P/S: I use Visual Studio Code to do this
Advertisement
Answer
Step 1: write this code in your html file
in form action redirect it to the php file
<!DOCTYPE html> <html> <head> <title>form</title> </head> <body> <form method="post" action="st.php"> <input type="text" name="text"> <input type="submit" name="submit_btn"> </form> </body> </html>
Step 2 create st.php file and call the action
<?php if(isset($_POST['submit_btn'])){ //your code header('Location:yourHTMLFile.html?status=success');//redirect to your html with status } ?>