PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Wassup all,
I am writing a simple reporting system that updates a status and records the date it was updated. The problem i'm running into is that my POST variables are not being set. I cannot figure out why. The page is in an iframe and it submits the form data to itself. However, I have tried testing it outside of iframes and submitting to separate pages but still get the same problem. PLEASE HELP!! Here is the necessary code from my update page.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
First things first, use [ php ] tags instead of code tags for PHP. Next, use $_REQUEST['QUERY_STRING']. Last, ave you echoed out any post vars to see what the form is sending? Maybe even before checking for isset() try doing a print_r($POST) and see what that does.
Hey Guys, thanks for the replys. Sry 'bout the code, i'm a forum newb. I tested the $_POST variables by placing an "else die" statement after the "if" statement that tests for the $_POST['MM_update'] variable. It dies everytime, so I figure that variable isn't set. I will try the print_r once i get back to my workstation. I will also try the two dimensional POST array, but it doesn't make sense to me how that would fix the problem.
I did a print_r before the POST variables are checked and after submitting the form, this is what is displayed.
Array ( [idnum] => Array ( [0] => 1 ) [date_updated] => Array ( [0] => 0 ) [status] => Array ( [0] => Signed profile sent in ) [submit] => Update [MM_update] => status [row_count] => 1 )
Warning: Cannot modify header information - headers already sent
The header warning part is not a problem in this case. It shows that they are being set correctly, so I must not be accessing them properly somewhere. I will go through it all again, but ANY help is appreciated.
Don't use isset on the $_POST array. Try strlen instead. In fact your isset condition is not even neccassry if you are checking if the value is "status" anyway.
Array (
[idnum] => Array (
[0] => 1)
[date_updated] => Array (
[0] => 0 )
[status] => Array (
[0] => Signed profile sent in )
[submit] => Update
[MM_update] => status
[row_count] => 1 )
This array output is telling me that the fieds 'idnum', date_updated' and 'status' are being sent as arrays instead of string vars. That means that you have your form fields named like 'name="fieldname[]"'. Is there a reason why these fields are arrays and the other are strings? If this is the intent of the script, maybe what you could do is at certain points within the script, 'break' your script with a call to die() ever now and again and echoing your vars to see what is being worked with.
I've tried various varieties of the same $POST variables check using isset, strlen, and so forth, but they all fail. The 'idnum', 'date_updated', and 'status' inputs are submitted as arrays because they are the three fields I am updating and I may need to update them on multiple records. So I have to use them as arrays to access them and make sure the corrct field is updated. They shouldn't have any affect on the "if" statement failing in my opinion however.
That is some weird code. There were a few errors in it, I'm not sure I found them all, but try this...
You were missing a $ in front of an x in a for loop, also you didn't have a closing ?> tag when you transitioned back into html. Is your error reporting turned off?
Wow, good job catching that $ before the x, Thanks. The closing tags are there, but I have a lot of code on that page so I only posted parts and pieces of it. That if statement is the big problem though, so I put up all the code relevant to it.