How can I add a relative path to submit an HTML form?
Asked Answered
R

3

7

I want to use a relative path for form submitting an HTML form. I have tried ./submit but it does not work.

CodeIgniter + Generated code:

echo form_open('./submit');
// <form action="http://example.com/./submit" method="post" accept-charset="utf-8">

This is what I want:

http://example.com/seekerpanel/changepassword/submit

And this is what I get:

http://example.com/submit

How can I address this path as relative to changepassword page?

Reglet answered 19/6, 2015 at 15:14 Comment(3)
Is the actual URL of the page the form is on http://domain.com/seekerpanel/changepassword/ ?Demonetize
Yes. and I'm using Code IgniterReglet
Any chance you could post the code for the actual form? The whole form tag would be nice to see. Also, are you using a <base> tag in your header? And finally, check the form with your browser's inspector, make sure the URL isn't being changed when the page is being loaded.Demonetize
R
0

I could do this using current_url function in url helper.

This generates the required output:

echo form_open(current_url().'/submit');
Reglet answered 17/6, 2020 at 13:7 Comment(0)
K
0

Now I don't think Anyone will come to this question because the issue of relative path was raised and resolved in 2015, But if anyone is getting error do check other parameter such as "method" and see to it that you have entered the correct value.

Kirchner answered 23/5, 2020 at 8:55 Comment(0)
R
0

I could do this using current_url function in url helper.

This generates the required output:

echo form_open(current_url().'/submit');
Reglet answered 17/6, 2020 at 13:7 Comment(0)
C
-3

Would you not just add the relative path http://example.com/seekerpanel/changepassword/submit into the action form attribute?

<form action="http://example.com/seekerpanel/changepassword/submit" method="get">
    <input type="submit" value="Submit">
</form>
Crunode answered 27/7, 2015 at 10:44 Comment(1)
because it's neither relative nor a path nor anything remotely resembling a good practice.Beard

© 2022 - 2024 — McMap. All rights reserved.