Search code examples
phpformseasyphp

Form not using the file in action attribute


I have a very simple HTML form that is supposed to send information to the file written in action attribute via GET but somehow it's transfering the information back to index.php:

index.php

<!doctype html>
<html>
<head>
    <title>Sandbox</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

<h1>PHP Forms Sandbox</h1>

<form acton="process_form.php" method="get">
    <label for="username">Username:</label>
    <input type="text" name="username" id="username" value="" />
    <label for="email">E-mail:</label>
    <input type="text" name="email" id="email" value="" />
    <input type="submit" name="submit_btn" id="submit_btn" value="Submit" />
</form>

</body>
</html>

process_form.php

<!doctype html>
<html>
<head>
    <title>Sandbox</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>

<h1>PHP Response Sandbox</h1>

<?php

$username = $_GET["username"];
$email = $_GET["email"];

echo $username . " : " . $email . "<br />";

?>

</body>
</html>

The bizarre aspect is that when I submit the form, the URL shows that it is not even using process_form.php:

http://127.0.0.1/Learning/?username=test&email=x%40test.com&submit_btn=Submit

If I manually change the URL to include process_form.php it seems to be working fine and I get the results I am looking for:

http://127.0.0.1/Learning/process_form.php?username=test&email=x%40test.com&submit_btn=Submit

On my development computer, I'm running EasyPHP 14.1 local WAMP server and thought it might be the root of the problem so I uploaded the files to my website that is running newest PHP on Apache, but the problem still exists there.

What am I doing wrong?


Solution

  • you have a typo error in action; you have given acton. Should be like this:

    <form action="process_form.php" method="get">