I'm using Wamp server to code a website on my PC, I'm following a tutorial on W3Schools for <form>
and data collection with PHP (the GET method) and even though I followed the tutorial the code doesn't work.
I researched it a little here but no one seems to be able to answer my problem.
<form action="welcome_get.php">
<section class="contact bg-primary" id="contact">
<div class="container">
<h2>Abonnez vous par mail!</h2>
<input type="email" id="email" size="50" placeholder="Entrez votre adresse e-mail"></input>
</div>
<div class="mail-submit">
<input type="submit" id="submit" value="Je m'abonne"></input>
</div>
</section>
</form>
That is the HTML before I send the email address, and this is the simple page to GET the email:
<html>
<body>
Your email address is: <?php echo $_GET["email"]; ?>
</body>
</html>
Yet it doesn't work at all. Here is the tutorial i followed
https://www.w3schools.com/php/php_forms.asp
I made a mistake. I was opening the FILE through my browser NOT accessing through Wampserver.
Now the issue is when I click on Submit button (that calls the
<form action="welcome_get.php" method="get">
) it downloads the welcome_get.php
.
First : add method GET
<form action="welcome_get.php" method="get">
Second : add attributte name in input
<input type="email" name="email" id="email" size="50" placeholder="Entrez votre adresse e-mail"></input>
Final : make sure your extension is .php not .html