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>
<p class="description">In order to vote in elections, you 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.