1
votes

In my HTML form I need the URL output like this: "example.com/mycontroller/action/mike/apple"

  • When I submit form with "post" my form values are not visible and can be get through "_POST". I don't prefer this because it makes output like this: "example.com/mycontroller/action/"
  • When I submit with "get" my form becomes "example.com/mycontroller/action?type=mike&key=apple"
  • I also don't prefer to change form action with javascript, like: "onSubmit take value of select and append it to form action" Because I don't want this snippet be javascript dependent.
  • I can submit form with "get" or "post" parse system variables of POST or GET and make a redirection. Like this: Redirect this "example.com/mycontroller/action?type=mike&key=apple" to this "example.com/mycontroller/action/mike/apple" But I didn't find this solution well designed. Is it possible to pass form values with slashes (other than questiın marks)

    < form class="well form-horizontal" id="myform" 
               method="get" action="/mycontroller/action" >
            <select name="type" id="type">
                <option value="mike" selected="selected">
                                    mickey bricks</option>
                <option value="albie">albert</option>
            </select>
    
            <input type="text" name="key" class="input-xlarge"
                         id="key" required="required">
    
            <button type="submit" class="btn btn-primary" id="submit">
                submit
            </button>
      </form>
    
1
what the url looks like should be the last thing you care about. - user557846
also - there is reason why the url of those forms will be the way it is for post/get - mark
Are these things (mike & apple) taken from the form values or are they known beforehand (before submission)? - dr Hannibal Lecter
@Dagon I care how URL looks like because cakephp accepts this form of URLs - trante
@dr Hannibal Mike is known beforehand. But apple is user's manual input. - trante

1 Answers

1
votes

If you make a POST form, it doesn't really matter where does it post to, what matters is where does it redirect. Many site searches redirect you to www.domain.com/search/search_terms so if this is a search form, there is nothing wrong with redirecting to ../action/mike/apple.

Additionally, if it is a POST form, it will not be filled in by the search crawlers (or at least not to my knowledge), so again it shouldn't matter where does the form post to, what matters is the return value and where does it redirect.

It all really depends on what are you trying to accomplish.