Hello,
I am a complete beginner with PHP so please bear with me!
So, I want to create a form, such as a feedback form, in my html file, which sends some information, such as name and email address, to a php file. To do this, I create a form in my html file, for example:
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Email: <input type="text" name="email" />
<input type="submit" />
</form>
</body>
</html>
Then, in my php file I write:
<html>
<body>
Thank you <?php echo $_POST["fname"]; ?>!<br />
You're email address is <?php echo $_POST["email"]; ?>.
</body>
</html>
However, when the submit button is clicked, the php script just displays a white page with the thank you message (showing the name and email address). What I want is to display this thank you message on the same page that the form was on in the original html file, rather than go to an entirely new page.
One solution I have thought of is to copy the entire contents of my html file, and put it into the php file, together with my thank you message. Then, this would show everything as it is in the original html file. But I'm confused as to whether this would then be an html file or a php file now - and whether all the links would work as with the original html file.
I'm sure there's a simpler was to do this - any help please??
Thank you!
Ed.