Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi,

 

I have a script that works OK but I'm not sure if it's by design or by accident.

 

On pages 91 through 94, Larry advises on how to use PHP redux, a technique that I use often.

 

Here's my scenario:

 

I have a PHP script, let's call it script one, that calls PHP script 2 and passes a key value to it.  I test for a key value as the first thing in script 2 via 'if (isset($GET['key']))' and retrieve its value. This works fine.

 

Then script 2 uses that key value to populate a form with values from a database select. The user is able to change any of the values in the form. Script 2 then calls itself via PHP redux.

 

Now this is the part that I don't quite understand.  The form is method=POST and that same key value is included in the form via an input type=hidden, a name of 'key', and the value via a PHP echo.

 

But the test for isset($GET['key']) still works and retrieves the correct value for key.  But the form is POST?  On the URL for the redux-called script two I can see the '?key=key-value suffix.

 

Can someone please help me understand this?

 

Thank you in anticipation.

Link to comment
Share on other sites

The action attribute value of your HTML form is the URL that the form will post to.

As such, if there is a ?name=value part on the end of the URL set for the action attribute, then you will be able to access that name-value pair via the GET method when you post the form.

If you don't want this, the simple solution is to not put the ?name=value part on the end of the URL specified for the action attribute of the form.

Link to comment
Share on other sites

Hi HartleySan,

 

I do not have an action value at all in my form.  Some time ago Larry advised to not use that when doing a redux - apparently it defaults to the current script URL and maybe that is why the GET/key is still there from the first call?

 

Thanks again for your interest and advice.

 

Cheers from Oz.

Link to comment
Share on other sites

It's very possible, but I don't know off the top of my head.

I usually hesitate from doing things like leaving attribute values blank, because the default behavior can differ from browser to browser.

I would recommend specifying an actual value, be it with or with out URL parameters.

Link to comment
Share on other sites

 Share

×
×
  • Create New...