View Single Post
  #12  
Old 03-04-2011, 12:18 AM
kvnband kvnband is offline
 
Join Date: Feb 2004
Location: AR
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So, I've made some progress. I thought I was doing good, until I went to create an update form. Does vBulletin have some sort of special trickery regarding $_POST? I have a basic update form that posts back to itself. But no matter what I do, I cannot get the dang thing to do anything. When I hit submit, I just get a blank page. Getting frustrated here...

Here is my PHP:

PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''voting_booth');
define('CSRF_PROTECTION'false);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('tsgvotingbooth',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

require_once(
'./global.php');

/****************************************
Define usergroups.  Will move to admincp eventually
****************************************/
$ug_voting_members=17;



/*****************************************
If the user is not logged in, kill it here
*****************************************/
//if(!isset($bbuserinfo['userid'])) {
//    print_no_permission();
//}

/*****************************************
List Elections
*****************************************/
if($_SERVER['REQUEST_METHOD']=='GET' && (!isset($_GET['do']) || $_GET['do'] == '')) {

}


/****************************************
Show registration form
****************************************/
else if($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['do'] == 'register') {
//print_r(get_defined_vars());
    
$navbits construct_navbits(array('' => 'Voting Booth Registration'));
    
$navbar render_navbar_template($navbits);
    
$pagetitle 'Voting Booth Registration';
    
    
$templater vB_Template::create('tsgvb_register_form');
    
$templater->register_page_templates();
    
$templater->register('navbar'$navbar);
    
$templater->register('pagetitle'$pagetitle);
    
$templater->register('ug_voting_members'$ug_voting_members);
    
print_output($templater->render());
}

else if(
$_SREVER['REQUEST_METHOD'] == 'POST' && $_POST['do'] == 'register') {
print_r($_POST);
}

?>
Here is my form template:
PHP Code:
{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <
head>
    <
title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {
vb:raw headinclude}
    {
vb:raw headinclude_bottom}
  </
head>
  <
body>
    
    {
vb:raw header}
    
    {
vb:raw navbar}
    
    <
div id="pagetitle">
      <
h1>{vb:raw pagetitle}</h1>
<
class="description">In order to vote in electionsyou must be registered.  Please fill out the following form to become a registered voter or to update your information.</p>

    </
div>
    
    <
h2 class="blockhead">Registration Form</h2>
    <
div class="blockbody formcontrols settings_form_border">
        <
fieldset class="blockrow">
            <
form action="voting_booth.php" method="post">
            <
input type="hidden" name="do" value="register" />
                <
legend>Registration Information</legend>
                <
ul class="group">
                    <
li>
                        <
label for="first_name">First Name: </label>
                        <
input type="text" name="first_name" id="first_name" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field5}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="last_name">Last Name: </label>
                        <
input type="text" name="last_name" id="last_name" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field6}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="phone">Phone Number: </label>
                        <
input type="text" name="phone" id="phone" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field7}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="street">Street Address: </label>
                        <
input type="text" name="street" id="street" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field8}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="city">City: </label>
                        <
input type="text" name="city" id="city" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field9}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="state">State: </label>
                        <
input type="text" size="2" name="state" id="state" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field10}"</vb:if> />
                    </
li>
                    <
li>
                        <
label for="zip">Zip Code: </label>
                        <
input type="text" name="zip" id="zip" <vb:if condition="is_member_of($bbuserinfo$ug_voting_members)">value="{vb:raw bbuserinfo.field11}"</vb:if> />
                    </
li>
                    <
li>
                        <
input type="submit" name="submit" value="Submit Registration Information" />
                    </
li>
                </
ul>
            </
form>
        </
fieldset>
      </
div>
    </
div>
    
    {
vb:raw footer}
  </
body>
</
html
The form loads up and looks fine, and is prefilled with the user's data, if it is available (I realize that this code is not exactly right, but it's working for now). But when I hit submit, I get a blank page, even though I have coded for it in the PHP file.

Obviously I'm missing something important here.

Any advice is appreciated.

--------------- Added [DATE]1299205201[/DATE] at [TIME]1299205201[/TIME] ---------------

Edit - Wow. I looked at this code for 20 minutes and couldn't figure out my problem. Posted here and almost instantly realized that I wrote $_SREVER instead of $_SERVER......

I'm leaving it here as a learning experience for others.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01184 seconds
  • Memory Usage 1,876KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete