Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Form doesn't take me to action url when submitting

When I submit my form it doesn’t take me to the right url, it instead just stays on the same url and adds the params to it. Like this: /todo?message=themessage rather than what it should be as /todo/add

<form>
<div class="form-group" action="/todo/add" method="POST">
     <label for="message">Add new todo message</label>
     <input type="text" class="form-control" name="message" id="message">
     <button type="submit" class="btn btn-primary">Add</button>
</div>
</form>

In my /todo/add url, I have a php script that is assigned to that route, which just echos a string and nothing else to see if the form hit that url, however it does not and just stays on the same page with the params.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You almost have it. All you need to do is to move the "action" and "method" attributes into the form tag instead of the div.

Since you don’t have the "action" in the form tag, the default behavior is to submit the form to the same page.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading