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

7.5k views Asked by At

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?

3

There are 3 answers

0
rostamiani On BEST ANSWER

I could do this using current_url function in url helper.

This generates the required output:

echo form_open(current_url().'/submit');
0
Varun Gupta On

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.

1
Tommy Davies On

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>