-2

I am trying to use an HTML form to submit the url index.php?page1&name2=value2&name3=Value3. The closest I've come is index.php?page1=&name2=value2...

I can't figure out how to get a clean page1 and I'm certain there's a simple answer. I'm not sure where to search but the MVC pattern I implemented (John Squibb's) assumes that format, I have to assume it's possible. Any information is appreciated.

What I have so far:

<form id="page1" action="index.php" method="get"> 
    <input type="hidden" name="page1"/>
    ... 
Ejaz
  • 8,719
  • 3
  • 34
  • 49
  • Post your complete HTML form – Ejaz Apr 28 '13 at 20:25
  • 1
    I fail to see how this relates to MVC at all – PeeHaa Apr 28 '13 at 20:28
  • F.C. - Thank you, but that results in "index.php?page=page1&..." PeeHaa - Great question ... I'm trying to call controllers from views. If there is a better way to call a controller from a view, I'm certainly willing to try it, but this is the assumption in the MVC pattern I implemented. Ejay - the actual HTML is for a POC I'm trying to set up related to enrolling for employee benefits and it too long for this text box. What is it you'd like to see? – user2329956 Apr 28 '13 at 20:37
  • There is no reason for a view to call a controller in MVC – PeeHaa Apr 28 '13 at 20:42
  • PeeHaa ... Interesting comment I'd like to better understand. In my example I'd like to login to a website, identify the benefits that are available to me, dig deeper into each benefit, and enroll in those that interest me with appropriate options. I as a user should only interact with the view, but I'd expect to controller to understand the models that need to be executed to get me the appropriate responses. How does the view interact with the models, if not through the controllers? – user2329956 Apr 28 '13 at 20:51
  • http://stackoverflow.com/questions/5863870/how-should-a-model-be-structured-in-mvc/5864000#5864000 – PeeHaa Apr 28 '13 at 21:03
  • user\d+, `I'm trying to call controllers from views`, AFAIK about MVC, In a HTTP request, your request is targeted at the front controller, i.e., index.php. Then the front contoller _loads_ the relevant controller and let's it do the job. Then while constructing the response, the controller _calls_ specific models, gathers data, constructs variables and passes them to view, and the variables can be accessed in view and displayed to the user. If your view is _calling_ the controller then it's not right MVC :D – Ejaz Apr 28 '13 at 21:05
  • Ejay - Yes, I mistyped. I am calling index.php ... the "page" is the name of the "service" I'm attempting to execute (e.g., findEmployee) which I'm assuming is the controller that understands the model(s) it needs to execute and the view it needs to return. PeeHaa - Thanks for sending that on. I'll admit to being an Old-School MVC guy having first learned it working with Smalltalk in the 90s. Having said that, I think I'm pretty close, following the view / controller pairing they suggest. The intent is that the models (currently stubs) will change once I get the basics correct. – user2329956 Apr 28 '13 at 21:24

1 Answers1

0

A clean page1 variable does not make much sense in this context.

When you submit a FORM, the browser decides how to encode your form variables into a query string (the part after the ?) that the browser then presents to the HTTP server. I could not find a standards document in a quick google search, but the Wikipedia page is quite good.

So the browser is choosing to encode page1, which has no value as page1=. This is what I would expect any browser to do. When your query string is processed on the server side, just about every language (PHP, Ruby, Python, etc...) should be able to handle this and will create a page1 variable with either a null or empty string value. If you're processing the query string on the client side (say with Javascript), you should find a library capable of parsing the query string.

What are you trying to accomplish? Why do you require the equal sign to be missing?

Andy Jones
  • 6,205
  • 4
  • 31
  • 47
  • Thank you Andy ... that makes sense based on what I've been reading. It sounds like my best bet is to modify my router to derive the next page from a name=value pair. I wonder why the MVC tutorial I followed did not do that (I'll have to follow up with the author). – user2329956 Apr 28 '13 at 20:45