Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2007, 05:49 AM
RobDog888's Avatar
RobDog888 RobDog888 is offline
 
Join Date: Apr 2007
Location: Degabah Swamp
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Admin CP Form

When creating a new admin control panel page I need to do some validation but maybe Im just staring at this too long.

Its not evaluating correctly and evals as true each and every time under any condition - blank or populated.

uploads_location is the input element name control.

Code:
if (empty($vbulletin->GPC['uploads_location']))
{
  print_stop_message('fieldmissing');
}
What am I doing wring lol?
Reply With Quote
  #2  
Old 09-30-2007, 09:05 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Run var_dump($vbulletin->GPC['uploads_location']); die(); on line above the code you posted and see what it returns. If it doesn't return anything you have probably made a typo in one of the names or something.
Reply With Quote
  #3  
Old 09-30-2007, 09:51 AM
RobDog888's Avatar
RobDog888 RobDog888 is offline
 
Join Date: Apr 2007
Location: Degabah Swamp
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, on the submitted page it printed out "NULL".

The spelling is correct and I use print_input_row with the second parameter as 'uploads_location' and third with a 'test' value. So its even loaded upon page load but if I type anyting into it or leave it as is it still evals to an empty field.

How should I be validating upon the submit? I already have a do value specified on the form opening line. I cant have it reload the page and eval the do with any variables passed as it will never match the if($_POST['do'] ==
Reply With Quote
  #4  
Old 09-30-2007, 10:08 AM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Part 1) What code are you using to clean the variable then?

Part 2) Submit it to another do action. e.g. if($_REQUEST['do'] == 'doadd') or something of the sort or you can add a hidden field to the form and check if that has been submitted in order to switch between processing the form or displaying the form.
Reply With Quote
  #5  
Old 09-30-2007, 04:58 PM
RobDog888's Avatar
RobDog888 RobDog888 is offline
 
Join Date: Apr 2007
Location: Degabah Swamp
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Clean? Im still new to vB and PHP but I think clean writes a value to a cookie?

So I should be storing the element id and value to a cookie using something like...
Code:
$vbulletin->input->clean_array_gpc('p', array(
	'uploads_location' => TYPE_STR,
	'txtUploadLocation' => TYPE STR'
));
If so, where would I place it?
Reply With Quote
  #6  
Old 09-30-2007, 05:08 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Doesn't that give you any parse errors? You have a rouge apostrophe after the TYPE STR, which should also be TYPE_STR.

Try this:
PHP Code:
$vbulletin->input->clean_array_gpc('p', array(
    
'uploads_location' => TYPE_STR,
    
'txtUploadLocation' => TYPE_STR
)); 
Reply With Quote
  #7  
Old 09-30-2007, 05:35 PM
RobDog888's Avatar
RobDog888 RobDog888 is offline
 
Join Date: Apr 2007
Location: Degabah Swamp
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok changes made (yes it did parse error but I hadnt updated my post yet ). Still doesnt read the inputbox value. I placed the code in the forms construction between the form tags.

I have searched the vB documentation over at vB.com and searched all over here too. Doesnt seem to be too much on form validation
Reply With Quote
  #8  
Old 09-30-2007, 07:39 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

run:
PHP Code:
var_dump($_POST['uploads_location']);
die(); 
To see if any data is being submitted to the code.
Reply With Quote
  #9  
Old 09-30-2007, 07:58 PM
RobDog888's Avatar
RobDog888 RobDog888 is offline
 
Join Date: Apr 2007
Location: Degabah Swamp
Posts: 293
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Arrg, still NULL.

This is what I have...

PHP Code:
// ...
print_form_header('mypage_admin''updatemanager');
print_table_header($vbphrase[my_manager]);
print_input_row('File Uploads Location:''uploads_location''testdata''false''50''260');
$vbulletin->input->clean_array_gpc('p', array(
  
'uploads_location' => TYPE_STR
));
print_submit_row($vbphrase['save'], $vbphrase['reset']);
print_table_footer(3''''0);
// ...
if ($_REQUEST['do'] == 'updatemanager')
{
  
// VALIDATE ENTERED DATA
  
var_dump($vbulletin->GPC['uploads_location']);
  die(); 
  if (!
$vbulletin->GPC['uploads_location'])
  {
    
print_stop_message('fieldmissing');
  }
}
// ... 
Reply With Quote
  #10  
Old 09-30-2007, 08:05 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try:
PHP Code:
// ...
if($_REQUEST['do'] == '')
{
    
print_form_header('mypage_admin''updatemanager');
    
print_table_header($vbphrase[my_manager]);
    
print_input_row('File Uploads Location:''uploads_location''testdata''false''50''260');
    
print_submit_row($vbphrase['save'], $vbphrase['reset']);
    
print_table_footer(3''''0);
}
// ...
elseif ($_REQUEST['do'] == 'updatemanager')
{
  
// VALIDATE ENTERED DATA
      
$vbulletin->input->clean_array_gpc('p', array(
          
'uploads_location' => TYPE_STR
    
));

  if (!
$vbulletin->GPC['uploads_location'])
  {
    
print_stop_message('fieldmissing');
  }

Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06158 seconds
  • Memory Usage 2,268KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete