Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 11 May 2011, 17:26
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Form error

I created a custom form in an if statement. The form will take you to the right page, but will not run the next $GET. If you refresh the page (by clicking enter in the URL box, not actually refreshing) it will run the next $GET. Any ideas as to why?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #2  
Old 11 May 2011, 19:34
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I don't notice anything wrong with that form, but user.php has no "do == banned" section so I'm assuming you've added that? In any case I don't know what "will not run the next $GET" means.
Reply With Quote
  #3  
Old 11 May 2011, 19:39
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
I don't notice anything wrong with that form, but user.php has no "do == banned" section so I'm assuming you've added that? In any case I don't know what "will not run the next $GET" means.
This is custom. By not run, I mean it will not do the user.php?do=banned&u=userID portion. It will put it in the URL and go to the search area, but it will not 'ban' the user. But if you hit enter in the URL it will go and 'ban' the user.
Reply With Quote
  #4  
Old 11 May 2011, 19:51
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
The default method for the form generated by print_form_header() is POST, so I guess what's happening is that you're getting 'do' and 'userid' in $_GET because you added them in the second parameter, but the other fields are in $_POST. You could either add the do and userid fields as hidden field in the form, or else set the method to get (it's like the ninth parameter or something). Or, you could use $_REQUEST[] which is a combination of $_GET, $_POST, and $_COOKIE.
Reply With Quote
  #5  
Old 11 May 2011, 20:00
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
The default method for the form generated by print_form_header() is POST, so I guess what's happening is that you're getting 'do' and 'userid' in $_GET because you added them in the second parameter, but the other fields are in $_POST. You could either add the do and userid fields as hidden field in the form, or else set the method to get (it's like the ninth parameter or something). Or, you could use $_REQUEST[] which is a combination of $_GET, $_POST, and $_COOKIE.
Sorry, I am using $_REQUEST.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #6  
Old 11 May 2011, 20:17
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
OK, sorry, I assumed you were using $_GET because you mentioned $GET.

But, I think I know what the problem is - the way you have it, you are ending up with do set to 'banned&u=' (plus whatever the userid is). So maybe you need to make u a hidden field in the form. (Edit: using 'do&u=' doesn't work)

Last edited by kh99; 11 May 2011 at 20:22.
Reply With Quote
  #7  
Old 11 May 2011, 20:22
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
OK, sorry, I assumed you were using $_GET because you mentioned $GET.

But, I think I know what the problem is - the way you have it, you are ending up with do set to 'banned&u=' (plus whatever the userid is). So maybe you need '&u=' as the second parameter, or else make u a hidden field in the form.
I changed it to "&u=" and it's still not working.
Reply With Quote
  #8  
Old 11 May 2011, 20:24
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Yeah, sorry. I decided to try that and found that it didn't work (and edited the above, but too late I guess). So I guess you have no choice but to make u a hidden field, or else just echo() your own form tag (plus the other stuff output by print_form_header())
Reply With Quote
  #9  
Old 11 May 2011, 20:27
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
Yeah, sorry. I decided to try that and found that it didn't work (and edited the above, but too late I guess). So I guess you have no choice but to make u a hidden field, or else just echo() your own form tag.
Why would a hidden field make this work?

Edit:
I added "echo $vbulletin->GPC['userid'];" right after I made the form and it gave me "Array['userid'] ".
^Not sure if that matters. It works if I put I call "$username" ($username = $vbulletin->GPC['userid']
Reply With Quote
  #10  
Old 11 May 2011, 20:42
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Artistichaven View Post
Why would a hidden field make this work?
That's a good question, and I just now figured it out: the print_form_header() function is adding do on the url *and* as a hidden field, and the hidden field value is run through htmlspecialchars(), so the '&' gets encoded and it looks like one field. I guess this hidden POSTed field is overriding the GET value for do on the url. So maybe your existing code would work if you used $_GET for do and u and $_REQUEST for the rest of the values.

I added "echo $vbulletin->GPC['userid'];" right after I made the form and it gave me "Array['userid'] ".
^Not sure if that matters. It works if I put I call "$username" ($username = $vbulletin->GPC['userid']
I think you need {$vbulletin->GPC['userid']} to make it so you don't get "Array['userid'] ".
Reply With Quote
  #11  
Old 11 May 2011, 20:48
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
That's a good question, and I just now figured it out: the print_form_header() function is adding do on the url *and* as a hidden field, and the hidden field value is run through htmlspecialchars(), so the '&' gets encoded and it looks like one field. I guess this hidden POSTed field is overriding the GET value for do on the url. So maybe your existing code would work if you used $_GET for do and u and $_REQUEST for the rest of the values.



I think you need {$vbulletin->GPC['userid']} to make it so you don't get "Array['userid'] ".
I changed it from if ($_REQUEST['do'] == 'banned') to $_GET and it didn't work. Maybe I should try displaying the URL.
Reply With Quote
  #12  
Old 11 May 2011, 21:03
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Yeah, I wish I understood this: I put a print_r($_GET) in the code and got this:

Array ( [do] => banned&u=1 [u] => 1 [userid] => 1 )

So somehow it's actually finding the u parameter, but insists on lumping it in with the do value as well. I changed the print_form_head() code to 'do=banned&u=1' and it makes no difference to what's in the $_GET array.
Reply With Quote
  #13  
Old 11 May 2011, 21:10
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
How did you check it?
Reply With Quote
  #14  
Old 11 May 2011, 21:13
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
I created a plugin using hook location misc_start and this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Then I go to url misc.php&do=form, then submit the form.

I think I'm going to try a non-vb test file and see if maybe some vb code is messing with $_GET[do].
Reply With Quote
  #15  
Old 11 May 2011, 21:19
Artistichaven Artistichaven is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
I created a plugin using hook location misc_start and this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Then I go to url misc.php&do=form, then submit the form.

I think I'm going to try a non-vb test file and see if maybe some vb code is messing with $_GET[do].

I got it to work! Your error here was "'banned&u='" it should have been "'banned&u="
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
A Better vBulletin (error) Message and Login Form View Mr_Snob vBulletin 3.6 Template Modifications 26 04 Apr 2009 18:45



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 14:37.

Layout Options | Width: Wide Color: