Joined: Aug 30, 2005 Posts: 2056 Location: near Albany NY
Posted:
Fri Aug 31, 2007 7:00 pm
I'm not positive but I think it has to be $_POST. Capitalized. You might also want to make it a habit to do an isset check on POST variables. Text type fields will always be passed in the POST array but checkboxes will not unless they are checked.
If I click on List Questions it does not go anywhere but just refreshes. The $op is not being passed to the switch $op I have at the bottom of my index page.
Joined: Aug 29, 2004 Posts: 7236 Location: Arizona
Posted:
Wed Sep 05, 2007 5:13 am
Donovan, the links that you are showing within your function admin_menu() are not coming from a form with a method of POST. Therefore, in this case, these are in $_GET....
I didn't know coding with registered globals on made things much easier to a novice PHP developer. Without them it has lead to a bunch of errors in my code. Alas, things are more secure with them off, but it takes some getting used to.
Joined: Aug 30, 2005 Posts: 2056 Location: near Albany NY
Posted:
Wed Sep 05, 2007 7:35 am
Donovan, working without register globals is really not complicated. You either have $_POST variables or $_GET. These are all contained in a POST or GET array. If you are using a form with a POST request method then the field names on the form are all POSTED automatically to the receiving or processing program. You will want to validate them on the receiving end. There is an extensive discussion of this here:
Only registered users can see links on this board! Get registered or login to the forums!
There is code in mainfile that turns register globals on (or I should say imports the variables) but I think there is general agreement that we would like to gradually convert Nuke so that we explicitly filter all variables rather than relying on implicitly importing them. That's going to take some doing since the old method permeates the core PHPnuke code. But for your new stuff you'd be better off getting familiar with the preferred approach. That's my opinion anyway.
Donovan, working without register globals is really not complicated. You either have $_POST variables or $_GET. These are all contained in a POST or GET array.
But if my admin_menu () did not have any form tags at all then the only way to find the value of $op was to $_GET?
Joined: Aug 30, 2005 Posts: 2056 Location: near Albany NY
Posted:
Wed Sep 05, 2007 8:12 am
Correct. You are either using the GET method or the POST one and in this case you are using GET. The important part is to conceptualize of user input (whether it be a form with POSTS or a selection that results in setting a GET) and the processing of that input as being a single integrated piece of code. Because of the nature of web architecture you can't total rely upon the fact that anything sent to your processing program comes from the source it says it comes from so you need to filter to assure that only legitimate variables (POSTS or GETS) are received and acted on.
I can list the questions and can choose which question I want to edit. Within the edit question function I have a textarea where the text is located but when I try and post that to a saveQuestion function all I am getting is the $cid of that question. I cannot pass the text or title of that question.
Joined: Aug 30, 2005 Posts: 2056 Location: near Albany NY
Posted:
Tue Sep 11, 2007 1:39 pm
I don't see any form tag with a method="post". In fact I just see a closing form tag and not an open one. Am I missing it? You can't post anything if your method isn't post. Furthermore you don't have an action attribute.
I'd recommend that you go entirely with posts and forget the gets. You might have one form that posts the cid and another that retrieves it and sticks the question in a textarea and then posts any edits that are done on that. I'd also recommend that you run what you have (or any amended version) thru the w3c validator. It will point out any missing tags. I also haven't seen that "while (list($key,)" syntax before. That may just be my inexperience but that comma looks suspicious to me. What's it there for?
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum