Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
Prev Previous Post   Next Post Next
  #1  
Old 12-22-2007, 10:37 PM
Oneback Oneback is offline
 
Join Date: Nov 2007
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Problem writing to the database

I am having a bit of a problem writing to the database using a form for a league hosting application I am developing. It is located outside of my forums subfolder (however I don't think that has anything to do with it).

Anyway here is the code:

register.php:

PHP Code:
<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''League Registration'); // 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(
    
'League Registration',
);

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

);

// ######################### REQUIRE BACK-END ############################
// ============================================
// Enter the full path to your forum here
// Example: /home/vbadvanced/public_html/forum
// ============================================

$forumpath '/apache/htdocs/forums/';

// ============================================
// No Further Editing Necessary!
// ============================================

if ($forumpath)
{
    if (!
is_dir($forumpath))
    {
        echo 
'Invalid forum path specified! Please edit this file and be sure to include the correct path for your $forumpath variable.';
        exit;
    }

    
chdir($forumpath);
}

require_once(
'./global.php');
require_once(
DIR '/includes/functions_user.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (!$vbulletin->userinfo['userid'])
{
    
print_no_permission();

$vbulletin->input->clean_gpc('r''a'TYPE_NOHTML);
$vbulletin->input->clean_gpc('r''u'TYPE_NOHTML);

$navbits = array();
$navbits[$parent] = 'League Registration';

$navbits construct_navbits($navbits);
eval(
'$navbar = "' fetch_template('navbar') . '";');
eval(
'print_output("' fetch_template('League Registration') . '");');


// ############################### start add league ###############################
if ($_POST['do'] == 'addleague')
{
    
//    clean data subbmitted by user    
    
$leaguename =                     $vbulletin->input->clean_gpc('p''leaguename'TYPE_STR);
    
$leaguepassword =                 $vbulletin->input->clean_gpc('p''leaguepassword'TYPE_STR);
    
$leaguepasswordconfirm =         $vbulletin->input->clean_gpc('p''leaguepasswordconfirm'TYPE_STR);
    
$console =                         $vbulletin->input->clean_gpc('p''console'TYPE_STR);
    
$game =                         $vbulletin->input->clean_gpc('p''game'TYPE_STR);
    
$numteams =                     $vbulletin->input->clean_gpc('p''numteams'TYPE_STR);
    
$numgames =                     $vbulletin->input->clean_gpc('p''numgames'TYPE_STR);
    
$adminid =                        $vbulletin->userinfo['userid'];

    
// League Name error checking
    
if (!$leaguename)
        {
            
standard_error('Please enter a league name.');
        }
        else 
            {
            
// Check length
            
$subleague stripslashes($leaguename);
             if(
strlen($subleague) < 6)
                {
                    
standard_error('League name is below 6 characters.');
                 }
            else if(
strlen($subleague) > 30)
                {
                    
standard_error('League name is above 30 characters.');
                 }
            
// Check if league name is not alphanumeric */
             
else if(!eregi("^([0-9a-z])+$"$subleague))
                {
                    
standard_error('League name is not alphanumeric.');
                 }
            }
    
    
// Password error checking
    
if(!$leaguepassword)
        {
            
standard_error('Password not entered.');
          }
        else
            {
             
// Check length
             
$subpass stripslashes($leaguepassword);
             if(
strlen($subpass) < 6)
                {
                    
standard_error('Password is below 6 characters.');
                 }
             
/* Check if password is not alphanumeric */
             
else if(!eregi("^([0-9a-z])+$", ($subpass trim($subpass))))
                {
                    
standard_error('Password is not alphanumeric.');
                 }
             
/* Confirm Password */
            
else if($subpass != $leaguepasswordconfirm
                {
                     
standard_error('Passwords do not match.');
                   }
            }
            
    
// Console error checking
    
if (!in_array($console, array(1234)))
        {
            
standard_error('Invalid console entered.');
        }    
    
    
// Game error checking
    
if (!in_array($game, array(123)))
        {
            
standard_error('Invalid game entered.');
        }
    
    
// Number of teams error checking
    
if (!in_array($numteams, array(1234567)))
        {
            
standard_error('Invalid number of teams entered.');
        }
        
    
// Number of games error checking
    
if (!in_array($numgames, array(12)))
        {
            
standard_error('Invalid number of games entered.');
        }
        
    
// save the data
    
$db->query_write("INSERT INTO " TABLE_PREFIX "leagues (adminid, leaguename, leaguepass, console, game, numteams, numgames) VALUES ($adminid$subleague$subpass$console$game$numteams$numgames)"); 
    
    
// redirect to leagues home
    
header("Location: http://localhost/leagues/index.php");
}
?>
League Register template:

PHP Code:
$stylevar[htmldoctype]
<
html dir="$stylevar[textdirection]lang="$stylevar[languagecode]xmlns="http://www.w3.org/1999/xhtml">
<
head>
<if 
condition="$pages['name'] == 'home'">
    <
meta http-equiv="Cache-Control" content="no-cache" />
    <
meta http-equiv="Pragma" content="no-cache" />
    <
meta http-equiv="Expires" content="0" />
</if>

<
title>$vboptions[hometitle] <if condition="$pagetitle">- $pagetitle</if></title>

$headinclude
</head>
<
body>
$header
$navbar
<br />
    <
table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="100%" align="center">
    <
tr>
        <
td class="tcat">Errors occured during registration</td>
    </
tr>
    <
tr>
        <
td class="alt1"><ul>$errorlist</ul></td>
    </
tr>
    </
table>
    <
br />

<
br />
<
table align="center" class="page" cellspacing="0" cellpadding="0" width="950">
    <
tr valign="top">
        <
td width="250" style="padding-right: 20px" bgcolor="#333333" align="left">
            <
div>
                <
table border="0" cellpadding="6" cellspacing="1" class="tborder" width="100%">
                    <
thead>
                        <
tr>
                            <
td class="tcat" colspan="0">
                                <
span class="smallfont"><strong>&raquoNavigation</strong></span></td>
                        </
tr>
                    </
thead>
                    <
tr>
                        <
td class="alt1">
                            <
div class="smallfont">&raquo; <a href="#"><strong>Home</strong></a></div>
                            <
div class="smallfont">&nbsp;&gt; <a href="register.php">Register League</a></div>
                            <
div class="smallfont">&nbsp;&gt; <a href="#">Join League</a></div>
                            <
div class="smallfont">&nbsp;&gt; <a href="#">Search League</a></div>
                            <
div class="smallfont">&nbsp;&gt; <a href="#">Support</a></div>
                        </
td>
                    </
tr>
                </
tbody>
                </
table>
            </
div>
            <
div style="padding-top:0px; margin-top:20px;">
                <
table border="0" cellpadding="6" cellspacing="1" class="tborder" width="100%">
                    <
thead>
                        <
tr>
                            <
td class="tcat" colspan="0">
                                <
span class="smallfont"><strong>&raquoAdvertisment</strong></span>
                            </
td>
                        </
tr>
                    </
thead>
                    <
tr>
                        <
td class="alt1" align="center">
                            <
script type="text/javascript"><!--
                                
google_ad_client "pub-1289182137012790";
                                
//200x200, created 12/19/07
                                
google_ad_slot "7532163925";
                                
google_ad_width 200;
                                
google_ad_height 200;
                            
//--></script>
                            
<script type="text/javascript"
                                
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                            </
script>
                        </
td>
                    </
tr>
                </
tbody>
                </
table>
            </
div>
        </
td>
        <
td valign="top" bgcolor="#333333" align="center">
            <
table border="0" cellpadding="6" cellspacing="1" class="tborder" width="100%">
                <
form action="register.php?do=addleague" name="register" method="post">
                     <
input type="hidden" name="s" value="$session[sessionhash]/>
                    <
input type="hidden" name="do" value="addleague" />
                    <
input type="hidden" name="url" value="$url/>
                    <
table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="100%" align="center">
                        <
tr>
                            <
td class="tcat"><strong>League Registration</strong></td>
                        </
tr>
                        <
tr>
                            <
td class="panelsurround" align="center">
                                <
div class="panel">
                                    <
div style="width:100%" align="left">
                                        <
div class="smallfont" style="margin-bottom: 10px">
                                            <
phrase 1="$vboptions[bbtitle]">Please fill out the form below to create a VirtualSportsDepot.com  LeagueLeague registration is easy and gives you instant access to  build and create your own leagueJust follow the simple steps below to  complete your registration.</phrase>
                                        </
div>
                                        <
div class="smallfont" style="margin-bottom: 10px">
                                            <
strong>League Name </strong>:<br />
                                            <
input type="text" class="bginput" name="leaguename" size="50" maxlength="50" value="$leaguename/>
                                        </
div>
                                    <
fieldset class="fieldset">
                                        <
legend>League Password</legend>
                                            <
table cellpadding="0" cellspacing="$stylevar[formspacer]border="0" width="100%">
                                                <
tr>
                                                    <
td colspan="2">Please enter a password for your leagueNote that passwords are case-sensitive.</td>
                                                </
tr>
                                                <
tr>
                                                    <
td>
                                                        
Password:<br />
                                                        <
input type="password" class="bginput" name="leaguepassword" size="25" maxlength="50" value="$password/>
                                                    </
td>
                                                    <
td>
                                                        
Confirm Password:<br />
                                                        <
input type="password" class="bginput" name="leaguepasswordconfirm" size="25" maxlength="50" value="$passwordconfirm/>
                                                    </
td>
                                                </
tr>
                                            </
table>
                                    </
fieldset>
                                    <
fieldset class="fieldset">
                                        <
legend>League Configuration</legend>
                                            <
table cellpadding="0" cellspacing="$stylevar[formspacer]border="0" width="100%">
                                                <
tr>
                                                    <
td>
                                                          <
label for="console">Console : </label> <br />
                                                          <
SELECT NAME="console" ID="console" SIZE="1">
                                                            <
OPTION value="" SELECTED></OPTION>
                                                            <
OPTION VALUE="1">PS2</OPTION>
                                                            <
OPTION VALUE="2">PS3</OPTION>
                                                            <
OPTION VALUE="3">XBOX</OPTION>
                                                            <
OPTION VALUE="4">XBOX 360</OPTION>
                                                        </
SELECT>
                                                    </
td>
                                                </
tr>
                                                <
tr>
                                                    <
td>
                                                          <
label for="game">Game : </label> <br />
                                                           <
SELECT NAME="game" ID="game" SIZE="1">
                                                            <
OPTION value="" SELECTED></OPTION>
                                                            <
OPTION VALUE="1">All Pro Football</OPTION>
                                                            <
OPTION VALUE="2">Madden Football</OPTION>
                                                            <
OPTION VALUE="3">NCAA Football</OPTION>
                                                        </
SELECT>
                                                    </
td>
                                                </
tr>
                                                <
tr>
                                                    <
td>
                                                          <
label for="teams">Number of Teams : </label> <br />
                                                          <
SELECT NAME="numteams" ID="numteams" SIZE="1">
                                                            <
OPTION value="" SELECTED></OPTION>
                                                            <
OPTION VALUE="1">8</OPTION>
                                                            <
OPTION VALUE="2">10</OPTION>
                                                            <
OPTION VALUE="3">12</OPTION>
                                                            <
OPTION VALUE="4">16</OPTION>
                                                            <
OPTION VALUE="5">20</OPTION>
                                                            <
OPTION VALUE="6">24</OPTION>
                                                            <
OPTION VALUE="7">32</OPTION>
                                                        </
SELECT>
                                                    </
td>
                                                </
tr>
                                                <
tr>
                                                    <
td>
                                                          <
label for="games">Number of Games: </label> <br />
                                                          <
SELECT NAME="numgames" ID="numgames" SIZE="1">
                                                            <
OPTION value="" SELECTED></OPTION>
                                                            <
OPTION VALUE="1">12</OPTION>
                                                            <
OPTION VALUE="2">16</OPTION>
                                                        </
SELECT>
                                                    </
td>
                                                </
tr>
                                            </
table>
                                    </
fieldset>
                                </
div>
                                <
div style="margin-top: 10px">
                                    <
input type="submit" class="button" value="Submit" />
                                </
div>
                            </
td>
                        </
tr>
                    </
table>
                </
form>
            </
table>
        </
td>
    </
tr>
</
table>
<
br />
$footer
</body>
</
html
If anyone could help out it would be greatly appreciated.

Thanks,

Oneback
Reply With Quote
 

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 04:19 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04419 seconds
  • Memory Usage 3,114KB
  • Queries Executed 12 (?)
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
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete