Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 08-04-2006, 08:27 PM
sokol sokol is offline
 
Join Date: Jun 2004
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Moding question.

MY INFO:
Vbulletin: 3.5.4
Vbadvanced: 2.1.0
GARS: 2.0 RC2 [commercial script]
Photopost: vbulletin enhanced [commercial script]

Ok, I run The Vanguard Library @ vanguardlibrary.com

I've been very busy getting my site layed out, and am now needing some very specic pages.

What I am looking for is ANY links and info on how to make custom pages with my own data read from the database, and another form for posting to the database.

MORE DETAIL:
Vanguard Library is a fansite for The Vanguard Saga of Heros game. I will be having info for races/classes/skills/spells etc.

I'm trying to determine the best way to go about this.
I need an admin page where people with admin rights can add/edit this info.
I need a user page where they will see the data entered.
I need a submit page that users can submit info and it will await for approval from an admin, then be posted.

All of the data pages I need will be very different.

I need any links or info on how to go about creating these.

My first thought was to use GARS however it does not seem like it is what I'm after here.

My second thought was to create the raceshow.php racesubmit.php etc...
The problem is I want it to use the vbulletin DB and I'm unsure of how to do this.
I can make my own db connection script, and use a different database, howver I then wont have the ability to use vbulletins permissions.

I know I've rambled, and if some kind soul PM's me I'd be glad to give more info and examples.

Thank you,
Sokol
Reply With Quote
  #2  
Old 08-04-2006, 11:51 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe the webtemplates mod by logician ?
Reply With Quote
  #3  
Old 08-05-2006, 12:14 AM
sokol sokol is offline
 
Join Date: Jun 2004
Posts: 32
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unless I misunderstood, Logicians Web templates are for reading from the DB, not wrting to.

Now I'm a newbie php coder, and code from example alot; so I'm mostly familiar with the code examples I've been.

I have a custom page, the custom page uses a custom template. Now all I need is to access the Vbulletin databse query functions. However I'm unsure how certain things differ.
For instance:

Code:
	// Validate the email address.	
	if (!empty($_POST['email'])) {
		$rn = escape_data($_POST['race_name']);
	} else {
		echo '<p><font color="red" size="+1">Please enter a Race Name address!</font></p>';
		$rn = FALSE;
	}
I think would now be

Code:
	// Validate the email address.	
	if (!empty($_POST['race_name'])) {
		$rn = escape_string($_POST['race_name']);
	} else {
		echo '<p><font color="red" size="+1">Please enter a Race Name</font></p>';
		$rn = FALSE;
	}
Ok I'm not certain but I think that would be correct for making sure the user entered info.

Now reading and writing to the Db confuses me abit more.

Code:
	if ($rn) { // If everything's OK.

		// Make sure the email address is available.
		$query = "SELECT race_name FROM races WHERE race_name='$rn'";		
		$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
		
		if (mysql_num_rows($result) == 0) { // Available.
This checks to make sure the race_name is available.

But how does vbulletin handle mysql_num_rows?

And how about writing to the database?

Code:
			$query = "INSERT INTO races (race_name) VALUES ('$rn',  NOW() )";		
			$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());

Again I'm pretty new to PHP and can code and adapt by example, but i'm abit stumped as to vbulletins mysql handling syntax.


-Sokol

Here is the NON vbulletin php file that I began to make.

Quote:
<?php
// This page allows users to add URL's to the database.
require_once('includes/mysql_connect.php'); //connect to the database [NOTE: change to default dir "../includes/mysql_connect" for production site.
if(isset($_POST['submitted'])) // Handle the form.
{
// Check for a URL title.
if(!empty($_POST['race_name']))
{
$rn = escape_data($_POST['race_name']);
}
else
{
$rn = FALSE;
echo '<p><font color="red">Please enter a Race Name.</font></p>';
}

if($rn) // If everything is filled in and OK.
{
// Add the user.
$raceid = @mysql_insert_id();
$query = "INSERT INTO races (race_name) VALUES ('$rn')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$raceid = @mysql_insert_id();

if($raceid > 0) // New URL has been added.
{
// Make the URL associations.
// Build query.
$query = 'INSERT INTO races (raceid) VALUES';
$query .= "($raceid), ";
$result = @mysql_query($query); // run the query.

// Send the email.
$body = "Thank you for posting a new Race.\n\n";
mail($_POST['dhoracek1@cox.net'], 'Registration Confirmation', $body, 'From: info@vanguardlibrary.com');
}

}
}
?>

<form action="race.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>">
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
mysql_close(); // Close the database connection.
?>
I can get it to work just fine adding race_name and auto incrementing.

Here is my vbulletin RACESUBMIT template

Quote:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title><phrase 1=$vboptions[bbtitle]>$vbphrase[x_powered_by_vbulletin]</phrase></title>
$headinclude
</head>
<body>
$header
$navbar
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;

<form action="racesubmit.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" >
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
</td>
</tr>
</table>
$footer
</body>
</html>
NOTE the value of the race_name field is not:
value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>
Anyw ay I can get my template file to allow me to add php into the template?

Here is my vbulletin code that formats my form into my vbulletin format.

Quote:
<?php
/* ADDED BY SOKOL for vba modules in forums */
define('VBA_PORTAL', true);
define('VBA_PAGE', 'include');
/* END ADD -SOKOL- */
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

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

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

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = array();
$navbits[$parent] = 'Race Submit';

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

// ################################################## #####################
// ######################## START DB SCRIPT ############################
// ################################################## #####################

// This page allows users to add URL's to the database.
require_once('includes/mysql_connect.php'); //connect to the database [NOTE: change to default dir "../includes/mysql_connect" for production site.
if(isset($_POST['submitted'])) // Handle the form.
{
// Check for a URL title.
if(!empty($_POST['race_name']))
{
$rn = escape_data($_POST['race_name']);
}
else
{
$rn = FALSE;
echo '<p><font color="red">Please enter a Race Name.</font></p>';
}

if($rn) // If everything is filled in and OK.
{
// Add the user.

$raceid = @mysql_insert_id();
$query = "INSERT INTO races (race_name) VALUES ('$rn')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$raceid = @mysql_insert_id();

if($raceid > 0) // New URL has been added.
{
// Make the URL associations.
// Build query.
$query = 'INSERT INTO races (raceid) VALUES';
$query .= "($raceid), ";
$result = @mysql_query($query); // run the query.

// Send the email.
$body = "Thank you for posting a new Race.\n\n";
mail($_POST['dhoracek1@cox.net'], 'Registration Confirmation', $body, 'From: info@vanguardlibrary.com');
}

}
}
?>

<form action="racesubmit.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>">
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
mysql_close(); // Close the database connection.
?>
So now my form displays: http://vanguardlibrary.com/racesubmit.php

and it seems to submit, but it will not update the database, and I'm assuming it's due to my RACESUBMIT template.

Any ideas?

Thanks a bunch,
Sokol
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 01:11 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.05145 seconds
  • Memory Usage 2,206KB
  • 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
  • (4)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete