This is a very basic question, but after learning both html and php online, I am having trouble with writing simple code. I have two separate files test.html and test.php. I have them saved on my desktop. When I open test.html in my browser(chrome), it works but when I click 'submit' query, it only prints:
Welcome:
your email address is:
What is it that I am doing wrong? Plus I want to ask how can I upload this on a web page?
This is the file: 'test.html'.
<!DOCTYPE HTML>
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
This is the file: 'test.php'
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
PHP needs a web server in order to be parsed - it does not have native support like HTML does. XAMPP is an example of such a web server, that also includes support for MySQL-databases. You'd need to install such a webserver and place your files inside of the htdocs folder. Once having done so, access the files by actually going to your local adress in the browser, typically: http://localhost/index.php
- or whatever you named your PHP/HTML file to.
EDIT
Commenter above also made a fair point. You set the form action to welcome.php, but you say this file is named test.php.