phpbb2 inserting posts code error (need Help)

Here you can find plenty of help with your general coding needs and projects
If it is about a specific program, use the corresponding forum
DO NOT ask basic questions such as "How do I print a variable", use Google for that

phpbb2 inserting posts code error (need Help)

Postby Knightkittens » Sat Oct 06, 2007 3:35 am

Tried a phpbb2 board with not so much as a reply.
so im turning to the many active members of this comunity.

My problem is (config file):
Defined here:


Code: Select all
//If you wish to use "Guest" as the poster, please enter exactly as follows: '-1'
//otherwise enter the id number of the user you want to post the form
$user = $userdata['3'];


The insert code
Code: Select all
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum, $user, '', $current_time, '$user_ip', 1, 1, 1, 1)";
   if (!$db->sql_query($sql, BEGIN_TRANSACTION))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);

}



$post_id = $db->sql_nextid();

Error code.

Code: Select all
DEBUG MODE

INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES (18, 2, , '', 1191560798, '1819bc87', 1, 1, 1, 1)



Code: Select all
SQL:
VALUES (18, 2, , '',


poster_id is empty, suggesting the information was not properly saved in the session.

I have probably staired at the code way to long and missing the obvious. But any help would be apriciated.
Knightkittens
WR.net Apprentice
WR.net Apprentice
 
Posts: 14
Joined: Sun Jul 16, 2006 12:29 am

phpbb2 inserting posts code error (need Help)

Postby zanix » Sat Oct 06, 2007 4:07 am

It might be a good idea to post all the code and not just sections of it
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5543
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

Re: phpbb2 inserting posts code error (need Help)

Postby Knightkittens » Sat Oct 06, 2007 12:46 pm

Sorry sure thing its a guild application form influanced and modified from scripts found here and netclerics work.
for phpbb2

ftw_app_form_Body.tpl
Code: Select all
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
   <tr>
      <td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></td>
   </tr>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
<form method="post" action="ftw_app_form_submit.php">
<table width="100%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td class="explaintitle">
Welcome!
If you are interested in joining <For The Win> then please fill out this
application form and submit it, we will get back to you as soon as
possible and in the mean time please enjoy our forums.<br />
Thank you</td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr>
<th><span class="genmed">Character Name:<br />
</span></td>
<th><span class="genmed">Level:<br />
</span></td>
<th><span class="genmed">Class:<br />
</span></td>
<th><span class="genmed">Timezone:<br />
</span></td>
<th><span class="genmed">Real Name: <br />
</span></td>
</tr>
<tr>
<td class="row2"><input name="charname" type="text" class="post" name="op1" size="15" /></td>

<td class="row2"><input name="charlevel" type="text" class="post" id="charlevel" size="2" maxlength="2" /></td>
<td class="row2"><select name="charclass" name="op7"">
  <option value="Druid">Druid</option>
  <option value="Hunter">Hunter</option>
  <option value="Mage">Mage</option>
  <option value="Paladin">Paladin</option>
  <option value="Priest">Priest</option>
  <option value="Rogue">Rogue</option>
  <option value="Shaman">Shaman</option>
  <option value="Warlock">Warlock</option>
  <option value="Warrior">Warrior</option>
</select></td>
<td class="row2"><select name="location" id="location">
  <option value="GMT-12">(GMT -12:00) Eniwetok, Kwajalein</option>
  <option value="GMT-11">(GMT -11:00) Midway Island, Samoa</option>
  <option value="GMT-10">(GMT -10:00) Hawaii</option>
  <option value="GMT-9">(GMT -9:00) Alaska</option>
  <option value="GMT-8">(GMT -8:00) Pacific Time (US & Canada)</option>
  <option value="GMT-7">(GMT -7:00) Mountain Time (US & Canada)</option>
  <option value="GMT-6">(GMT -6:00) Central Time (US & Canada), Mexico City</option>
  <option value="GMT-5">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option>
  <option value="GMT-4">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
  <option value="GMT-3.5">(GMT -3:30) Newfoundland</option>
  <option value="GMT-3">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
  <option value="GMT-2">(GMT -2:00) Mid-Atlantic</option>
  <option value="GMT-1">(GMT -1:00 hour) Azores, Cape Verde Islands</option>
  <option value="GMT">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
  <option value="GMT+1" selected="selected">(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option>
  <option value="GMT+2">(GMT +2:00) Kaliningrad, South Africa</option>
  <option value="GMT+3">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
  <option value="GMT+3.5">(GMT +3:30) Tehran</option>
  <option value="GMT+4">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
  <option value="GMT+4.5">(GMT +4:30) Kabul</option>
  <option value="GMT+5">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
  <option value="GMT+5.5">(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
  <option value="GMT+6">(GMT +6:00) Almaty, Dhaka, Colombo</option>
  <option value="GMT+7">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
  <option value="GMT+8">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
  <option value="GMT+9">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
  <option value="GMT+9.5">(GMT +9:30) Adelaide, Darwin</option>
  <option value="GMT+10">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
  <option value="GMT+11">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
  <option value="GMT+12">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
</select></td>
<td class="row2"><input name="realname" type="text" class="post" id="realname" size=
"30" /></td>
</tr>
</table>
<br />
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr>

<th nowrap="nowrap"><span class="genmed">Availability: <span class="gensmall">We raid 7:00pm - 11:30pm (Server Time)</span></th>
<th>Age:</th>
<th><span class="genmed">Abuse Tolorance level?</span></th>
</tr>
<tr class="row1">
<td nowrap="nowrap"><input name="day7" type="checkbox" id="day7" value="Yes, " />Sun  <input name="day1"
type="checkbox" id="day1" value="Yes, " />Mon  <input name="day2" type="checkbox" id="day2" value="Yes, " />Tue 
<input name="day3" type="checkbox" id="day3" value="Yes, " />Wed  <input name="day4" type="checkbox" id="day4" value="Yes, " />Thu  <input name="day5" type="checkbox" id="day5" value="Yes, " />Fri  <input name="day6" type="checkbox" id="day6" value="Yes," />Sat</td>

<td class="row2"><input name="playerage" type="text" class="post" size="2" maxlength="2" /></td>
<td class="row2"><select name="tolorance" id="tolorance">
  <option selected="selected">Extreme</option>
  <option>High</option>
  <option>Medium</option>
  <option>Low</option>
</select></td>
</tr>
</table>
<br />
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr>
<th><span class="genmed">Reputation - Do you have revered or exhalted with?:</span></td>
<th valign="top"><span class="genmed">Instance Keys/Attunement:</span></th>
<th valign="top"><span class="genmed">Trade Skills:</span></th>
</tr>
<tr>
<td class="row2"><input name="thrallrep" type="checkbox" id="thrallrep" value=
"Yes, " />
  Honour Hold <br />
  <input name="cenrep" type="checkbox" id="cenrep" value=
"Yes, " />
  Cenarion Expedition <br />
  <input name="lowerrep" type="checkbox" id="lowerrep" value=
"Yes, " />
  Lower City <br />
  <input name="sharep" type="checkbox" id="sharep" value=
"Yes, " />
  The Sha'tar <br />
  <input name="keeprep" type="checkbox" id="keeprep" value=
"Yes," />
  Keepers of Time<br /></td>
<td class="row2"><input name="karatune" type="checkbox" id="karatune" value=
"Yes, " />
  Karazhan <br />
  <input name="temptune" type="checkbox" id="temptune" value=
"Yes, " />
  The Tempest Key <br />
  <input name="serptune" type="checkbox" id="serptune" value=
"Yes, " />
  Serpentshire Cavern <br />
  <input name="onytune" type="checkbox" id="onytune" value=
"Yes," />
  Mt. Hyjal</td>
<td class="row2"><select name="prof1" id="prof1">
  <option disabled="disabled" selected="selected">Profession 1</option>
  <option>Gathering/Herbalism</option>
  <option>Gathering/Mining</option>
  <option>Gathering/Skinning</option>
  <option>Alchemy</option>
  <option>Alchemy/ Master of Potions</option>
  <option>Alchemy/ Master of Elixirs</option>
  <option>Alchemy/ Master of Transmutation</option>
  <option>Blacksmithing/Armor</option>
  <option>Blacksmithing/Axe</option>
  <option>Blacksmithing/Hammer</option>
  <option>Blacksmithing/Sword</option>
  <option>Enchanting</option>
  <option>Engineering/Gnomish</option>
  <option>Engineering/Goblin</option>
  <option>Jewelcrafting</option>
  <option>Leatherworking/Dragonscale</option>
  <option>Leatherworking/Elemental</option>
  <option>Leatherworking/Tribal</option>
  <option>Tailoring</option>
  <option>Tailoring/Mooncloth</option>
  <option>Tailoring/Shadoweave</option>
  <option>Tailoring/Spellfire</option>
</select>
  <br />
  <br />
  <select name="prof2" id="prof2">
    <option disabled="disabled" selected="selected">Profession 2</option>
    <option>Gathering/Herbalism</option>
    <option>Gathering/Mining</option>
    <option>Gathering/Skinning</option>
    <option>Alchemy</option>
    <option>Alchemy/ Master of Potions</option>
    <option>Alchemy/ Master of Elixirs</option>
    <option>Alchemy/ Master of Transmutation</option>
    <option>Blacksmithing/Armor</option>
    <option>Blacksmithing/Axe</option>
    <option>Blacksmithing/Hammer</option>
    <option>Blacksmithing/Sword</option>
    <option>Enchanting</option>
    <option>Engineering/Gnomish</option>
    <option>Engineering/Goblin</option>
    <option>Jewelcrafting</option>
    <option>Leatherworking/Dragonscale</option>
    <option>Leatherworking/Elemental</option>
    <option>Leatherworking/Tribal</option>
    <option>Tailoring</option>
    <option>Tailoring/Mooncloth</option>
    <option>Tailoring/Shadoweave</option>
    <option>Tailoring/Spellfire</option>
    <option>None</option>
  </select></td>
</tr>
</table>
<br />
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr class="row2">
<th><span class="genmed">Why do you want to join and why would we want you?:</span></th>
<th><span class="genmed">Previous Guilds (Include guild names, realms names & why you left):</span></td>
<th><span class="genmed">Raiding experience</span></th>
</tr>
<tr class="row1">
<td>
<div style="text-align:center">
<textarea class="post" name="whyjoin" cols="27" rows="5" id="whyjoin" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post">
</textarea class="post"></div></td>
<td>
<div style="text-align:center">
<textarea class="post" name="prevguild" cols="27" rows="5" id="prevguild" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post">
</textarea class="post"></div></td>
<td class="row2">
<div style="text-align:center">
<textarea class="post" name="preraidexp" cols="27" rows="5" id="preraidexp" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post" class="post">
</textarea class="post"></div></td>
</tr>
</table>
<br />
<table width="100%" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr>
<th><span class="style2">Any additional Information?</span></td>

</tr>
<tr>
<td class="row2"><div style="text-align:center">
<textarea class="post" name="additional" cols="90" rows="5" id="additional">

</textarea></div></td>
</tr>
</table>
<br />
<table width="100%" align="center" cellpadding="3" cellspacing="1" class="forumline">
<tr>
<th>Do you have friends in <For The Win>? (Please Name them)</th>
<th>Are you a Cross Realm Applicant? </th>
</tr>
<tr>
<td class="row2"><div style="text-align:center">
<textarea class="post" name="friends" cols="45" rows="5" id="friends">

</textarea></div></td>

<td class="row2"><div style="text-align:center">
<select name="xrealm" id="xrealm">
<option selected="selected">No</option>
<option>Yes</option>
</select></div></div></td>
</tr>
</table>
<br />
<div align="center"> <strong><font
 color="#">Alternate Character Information</font></strong></div>
<div align="center"><strong>List any alternate
characters you wish to bring into the guild:</strong> <br>
<font color="#ffff00">*</font> Required if alternate
character name is entered </div>
<table align="center" border="0" width="507">
  <tbody>
    <tr>
      <td width="254"><strong>Name</strong> 
      <input id="Alt1Name" name="Alt1Name" value=""
 size="35" type="text"></td>
      <td width="164"><strong>Class</strong>
      <select id="Alt1Class" name="Alt1Class">
      <option value="10" selected="selected">Select
a Class</option>
      <option value="1">Warrior</option>
      <option value="2">Hunter</option>
      <option value="3">Rogue</option>
      <option value="4">Priest</option>
      <option value="5">Shaman</option>
      <option value="6">Druid</option>
      <option value="7">Mage</option>
      <option value="8">Warlock</option>
      <option value="9">Paladin</option>
      </select>
      <font color="#ffff00">*</font> </td>
      <td width="75"><strong>Level</strong> <input
 id="Alt1Level" name="Alt1Level" value="" size="2"
 maxlength="2" type="text"> <font color="#ffff00">*</font>
      </td>
    </tr>
    <tr>
      <td><strong>Name</strong> 
      <input id="Alt2Name" name="Alt2Name" value=""
 size="35" type="text"></td>
      <td><strong>Class</strong>
      <select id="Alt2Class" name="Alt2Class">
      <option value="10" selected="selected">Select
a Class</option>
      <option value="1">Warrior</option>
      <option value="2">Hunter</option>
      <option value="3">Rogue</option>
      <option value="4">Priest</option>
      <option value="5">Shaman</option>
      <option value="6">Druid</option>
      <option value="7">Mage</option>
      <option value="8">Warlock</option>
      <option value="9">Paladin</option>
      </select>
      <font color="#ffff00">*</font> </td>
      <td><strong>Level</strong> <input
 id="Alt2Level" name="Alt2Level" value="" size="2"
 maxlength="2" type="text"> <font color="#ffff00">*</font>
      </td>
    </tr>
    <tr>
      <td><strong>Name</strong> 
      <input id="Alt3Name" name="Alt3Name" value=""
 size="35" type="text"></td>
      <td><strong>Class</strong>
      <select id="Alt3Class" name="Alt3Class">
      <option value="10" selected="selected">Select
a Class</option>
      <option value="1">Warrior</option>
      <option value="2">Hunter</option>
      <option value="3">Rogue</option>
      <option value="4">Priest</option>
      <option value="5">Shaman</option>
      <option value="6">Druid</option>
      <option value="7">Mage</option>
      <option value="8">Warlock</option>
      <option value="9">Paladin</option>
      </select>
      <font color="#ffff00">*</font> </td>
      <td><strong>Level</strong> <input
 id="Alt3Level" name="Alt3Level" value="" size="2"
 maxlength="2" type="text"> <font color="#ffff00">*</font>
      </td>
    </tr>
  </tbody>
</table>
 
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="forumline">
<tr>
<td class="cat" align="center"><input type="submit" name="submit" value="Apply" class="mainoption"/> <input type="reset" value="Reset" name="Reset" class="liteoption" /></td>    </td>
</tr>
</table>
</form>


ftw_app_form.php
Code: Select all
<?php
 
// standard hack prevention
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

//
// standard session management
//
$userdata = session_pagestart($user_ip, PAGE_FAQ);
init_userprefs($userdata);

// set page title
$page_title = "FTW Applciation";

// standard page header
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

// Kick out those who do not belong
// if ($userdata['username'] == "Anonymous")
//   message_die(GENERAL_ERROR, "You need to be logged in to be able to access this page.");


$template->set_filenames(array(
   'body' => 'ftw_app_form_body.tpl')
   );

$template->pparse('body');

//standard page footer
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>


ftw_app_form_submit.php
Code: Select all
<?php

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//Enter the title that will be displayed at the top of the browser
$title = "FTW Applciation";

//Name of the file that contains the html
$tpl_file = 'ftw_app_form_successful.tpl';

$userdata = session_pagestart($user_ip, PAGE_LOGIN);
init_userprefs($userdata);

// Details
$charname = $_POST["charname"];
$charclass = $_POST["charclass"];
$location = $_POST["location"];
$realname = $_POST["realname"];
$day7 = $_POST["day7"];
$day1 = $_POST["day1"];
$day2 = $_POST["day2"];
$day3 = $_POST["day3"];
$day4 = $_POST["day4"];
$day5 = $_POST["day5"];
$day6 = $_POST["day6"];
$charlevel = $_POST["charlevel"];
$tolorance = $_POST["tolorance"];
$thrallrep = $_POST["thrallrep"];
$cenrep = $_POST["cenrep"];
$lowerrep = $_POST["lowerrep"];
$sharep = $_POST["sharrep"];
$keeprep = $_POST["keeprep"];
$karatune = $_POST["karatune"];
$temptune = $_POST["temptune"];
$serptune = $_POST["serptune"];
$onytune = $_POST["onytune"];
$prof1 = $_POST["prof1"];
$prof2 = $_POST["prof2"];
$whyjoin = $_POST["whyjoin"];
$prevguild = $_POST["prevguild"];
$preraidexp = $_POST["preraidexp"];
$additional = $_POST["additional"];
$friends = $_POST["friends"];
$xrealms = $_POST["xrealms"];
$alt1name = $_POST["alt1name"];
$alt1class = $_POST["alt1class"];
$alt1level = $_POST["alt1level"];
$alt2name = $_POST["alt2name"];
$alt2class = $_POST["alt2class"];
$alt2level = $_POST["alt2level"];
$alt3name = $_POST["alt3name"];
$alt3class = $_POST["alt3class"];
$alt3level = $_POST["alt3level"];
$submit = $_POST["submit"];
/*              //example Details
$op1 = $_POST["op1"];
$op2 = $_POST["op2"];
$op3 = $_POST["op3"];
$op4 = $_POST["op4"];
$op5 = $_POST["op5"];
$op6 = $_POST["op6"];
$op7 = $_POST["op7"];
$email = $_POST["email"];
*/

//enter the email message here, can contain spaces and<Enter> as long as it is between the " "
//anytime you want to use a variable, enter it as $op1 or whatever where you want to use it
//"$op1, $op2, $op3, $op4, $op5, $op6, $op7";
$message = "$charname, $charclass, $location, $realname, $day7, $day1, $day2, $day3, $day4, $day5, $day6,
$charlevel, $tolorance, $thrallrep, $cenrep, $lowerrep, $sharep, $keeprep, $karatune,
$temptune, $serptune, $onytune, $prof1, $prof2, $whyjoin, $prevguild, $preraidexp,
$additional, $friends, $xrealms, $alt1name, $alt1class, $alt1level, $alt2name, $alt2class,
$alt2level, $alt3name, $alt3class, $alt3level, $submit,"
//Message for the post here, can contain spaces and <Enter> as long as it is between the " "
$post_message = "
Character Name:         Class:              Level:
ANSWER: $charname       ANSWER: $charclass  ANSWER:$charlevel

Timezone:               Availability:
ANSWER: $location       ANSWER: $day7, $day1, $day2, $day3, $day4, $day5, $day6,

Reputation:             Instance Keys/Attunement:   Trade Skills:
ANSWER: $thrallrep      Awnser: $karatune            Awnser: $prof1
      $cenrep                 $temptune                    $prof2
      $lowerrep               $serptune
      $sharep                 $onytune
      $keeprep
      $karatune

1. Why do you want to join and why would we want you:
ANSWER:  $whyjoin

2. Previous Guilds (Include guild names, realms names & why you left):
ANSWER: $prevguild

3. Raiding experience:
ANSWER: $preraidexp

4. Any additional Information!:
ANSWER: $additional

5. Do you have friends in ? (Please Name them):
ANSWER: $friends

6. Are you a Cross Realm Applicant?
ANSWER: $xrealms

Alternate Character Name:    Alternate Class:         Alternate Level
Awnser: $alt1name            Awnser: $alt1class       Awnser: $alt1level
        $alt2name                    $alt2class               $alt2level
        $alt3name                    $alt3class               $alt2level";
$current_time = time();

//Post a new topic?
$new_topic = 'yes';
//Please enter the forum id number and the id number of the user that will be used for the post:
$forum = 2;
//If you wish to use "Guest" as the poster, please enter exactly as follows: '-1'
//otherwise enter the id number of the user you want to post the form
$user = $userdata['3'];
//Enter the title for the topic
$topic_title = "$charname Guild Application";


//If you want a new poll but do not want a new topic, this script will create a new topic and make a poll as one message
//To have it create the poll in a serate forum, you must say yes to new topic, yes to poll, and no to same forum
//Post poll?
$post_poll = 'no';
//Do you want the poll in the same forum as the post or a different forum?
$same_forum = 'no';
//Enter the forum id number of the forum you want the poll in
//ONLY IF YOU WANT THE POLL IN A DIFFERENT FORUM THAN THE POST
$poll_forum_id = 8;
//Message to be displayed in the post if you choose to post the poll in a different forum
$poll_message = "
Character Name:         Class:              Level:
ANSWER: $charname       ANSWER: $charclass  ANSWER:$charlevel

Timezone:               Availability:
ANSWER: $location       ANSWER: $day7, $day1, $day2, $day3, $day4, $day5, $day6,

Reputation:             Instance Keys/Attunement:   Trade Skills:
ANSWER: $thrallrep      Awnser: $karatune            Awnser: $prof1
      $cenrep                 $temptune                    $prof2
      $lowerrep               $serptune
      $sharep                 $onytune
      $keeprep
      $karatune,

1. Why do you want to join and why would we want you:
ANSWER:  $whyjoin

2. Previous Guilds (Include guild names, realms names & why you left):
ANSWER: $prevguild

3. Raiding experience:
ANSWER: $preraidexp

4. Any additional Information!:
ANSWER: $additional

5. Do you have friends in ? (Please Name them):
ANSWER: $friends

6. Are you a Cross Realm Applicant?
ANSWER: $xrealms

Alternate Character Name:    Alternate Class:         Alternate Level
Awnser: $alt1name            Awnser: $alt1class       Awnser: $alt1level
        $alt2name                    $alt2class               $alt2level
        $alt3name                    $alt3class               $alt2level";

//Poll time length in days. Please enter 0 for unlimited
$poll_length = 30;
//Poll options
//No less than 2 options and no more than 5 can be used
//To add options use the following example for max options
//EX: array('1'=> 'Op 1 Txt', '2' => 'Op 2 Txt', '3' => 'Op 3 Txt', '4' => 'Op 4 Txt', '5' => 'Op 5 Txt');
$poll_options = array(
   '1' => 'Yes',
   '2' => 'No');
//Poll title
$poll_title = "Should we recruit $charname, $charclass $charlevel";



//Send PM?
$send_pm = 'no';
//User's ID that will receive the PM
$pm_user_id = 2;
//Message that the user will receive
$pm_message = "PM message, can also contain spaces and enters";

//Send email to admin?
$email_admin = 'no';
// Enter your email address
$to ="application@4thewin.org";
$subject = "NEW APPLICANT";
// From
$header="from: <$email>";


//Send successfull submission email?
$success_email = 'yes';
//email message to send to applicant upon successful submission
$success_subject = "SUCCESS!  You have completed a application for FTW";
//enter the name that will appear to the receiver of the success email
$success_header = "Thank You for applying to <For The Win>.";
$success_email = "Once our staff of finely-honed gamers reviews your application, someone will contact you for a little more personal one-on-one session. Until then, we at FTW hope you enjoy your gaming experience in WoW!";

//Test to see if any options are set DO NOT MODIFY THIS LINE
if ($new_topic == 'no' && $post_poll == 'no' && $send_pm == 'no' && $email_admin == 'no' && $success_email == 'no')
   {
      die("There are no options set, please set some options for form submission");
   }



//start the process of emailing and posting
//Here is where you set the options that are required to be filled out for submission
//EX: if(!$variable == '' && !$variable2 =='')
//be sure to put at least one variable as required, and && between multiple variables
if (!$email == '')
{
// WARNING: NO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW ABSOLUTLY WHAT YOU ARE DOING!!!!!!!!!!!
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ($email_admin == 'yes')
  {
    mail($to, $subject, $message, $header);
  }
  if ($success_email == 'yes')
  {
    mail($email, $success_subject, $success_email, $success_header);
  }
if ($new_topic == 'yes' || ($new_topic == 'no' && $post_poll == 'yes'))
{
   
$sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$topic_title', '$user', $current_time, $forum, " . TOPIC_UNLOCKED . ", 0, 0)";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }


         $topic_id = $db->sql_nextid();
         
   
   
   
   $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum, $user, '', $current_time, '$user_ip', 1, 1, 1, 1)";
   if (!$db->sql_query($sql, BEGIN_TRANSACTION))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }


      $post_id = $db->sql_nextid();


   $sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$post_message')";
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }
   

//update forum stats
   $forum_update_sql = "forum_posts = forum_posts + 1, forum_last_post_id = $post_id, forum_topics = forum_topics + 1";
   $topic_update_sql = "topic_last_post_id = $post_id, topic_first_post_id = $post_id";
      
      $sql = "UPDATE " . FORUMS_TABLE . " SET $forum_update_sql WHERE forum_id = $forum";
   
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }


      $sql = "UPDATE " . TOPICS_TABLE . " SET $topic_update_sql WHERE topic_id = $topic_id";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   

   if (!$user == '-1')
   {
      $sql = "UPDATE " . USERS_TABLE . "SET user_posts = user_posts + 1 WHERE user_id = $user";
      if (!$db->sql_query($sql, END_TRANSACTION))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   }
   
if ($post_poll == 'yes')
{
   if($same_forum == 'no' && $new_topic == 'yes')
   {
      $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$poll_title', '$user', $current_time, $poll_forum_id, " . TOPIC_UNLOCKED . ", 0, 1)";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }


         $topic_id = $db->sql_nextid();
         
   
   
   
   $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $poll_forum_id, $user, '', $current_time, '$user_ip', 1, 1, 1, 1)";
   if (!$db->sql_query($sql, BEGIN_TRANSACTION))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }


      $post_id = $db->sql_nextid();


   $sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($post_id, '$post_subject', '$bbcode_uid', '$poll_message')";
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }
   

//update forum stats -- for posting the poll
   $forum_update_sql = "forum_posts = forum_posts + 1, forum_last_post_id = $post_id, forum_topics = forum_topics + 1";
   $topic_update_sql = "topic_last_post_id = $post_id, topic_first_post_id = $post_id";
      
      $sql = "UPDATE " . FORUMS_TABLE . " SET $forum_update_sql WHERE forum_id = $poll_forum_id";
   
   if (!$db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
   }


      $sql = "UPDATE " . TOPICS_TABLE . " SET $topic_update_sql WHERE topic_id = $topic_id";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   

   if (!$user == '-1')
   {
      $sql = "UPDATE " . USERS_TABLE . "SET user_posts = user_posts + 1 WHERE user_id = $user";
      if (!$db->sql_query($sql, END_TRANSACTION))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   }
   
   $sql = "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ($topic_id, '$poll_title', $current_time, " . ($poll_length * 86400) . ")";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
      
      $poll_id = $db->sql_nextid();
      
      
      $poll_option_id = 1;
      while (list($option_id, $option_text) = each($poll_options))
      {
         if (!empty($option_text))
         {
            $option_text = str_replace("\'", "''", htmlspecialchars($option_text));
            $poll_result = 0;

            $sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ($poll_id, $poll_option_id, '$option_text', $poll_result)";
            if (!$db->sql_query($sql))
            {
               message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
            }
            $poll_option_id++;
         }
      }
      
      $sql = "UPDATE " . TOPICS_TABLE . " SET topic_vote = 1 WHERE topic_id = $topic_id";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   }//end different forum
   else
   {
   $sql = "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ($topic_id, '$poll_title', $current_time, " . ($poll_length * 86400) . ")";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
      
      $poll_id = $db->sql_nextid();
      
      
      $poll_option_id = 1;
      while (list($option_id, $option_text) = each($poll_options))
      {
         if (!empty($option_text))
         {
            $option_text = str_replace("\'", "''", htmlspecialchars($option_text));
            $poll_result = 0;

            $sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ($poll_id, $poll_option_id, '$option_text', $poll_result)";
            if (!$db->sql_query($sql))
            {
               message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
            }
            $poll_option_id++;
         }
      }
      
      $sql = "UPDATE " . TOPICS_TABLE . " SET topic_vote = 1 WHERE topic_id = $topic_id";
      if (!$db->sql_query($sql))
      {
         message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
      }
   }//end same original post
}//end poll
}//end new topic
      
//PM
if ($send_pm == 'yes')
{
      $sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
      VALUES (" . PRIVMSGS_NEW_MAIL . ", '$gname Application', $user, $pm_user_id, $current_time, '$user_ip', 0, 1, 1, 1)";

   if ( !$db->sql_query($sql_info, BEGIN_TRANSACTION) )
   {
      message_die(GENERAL_ERROR, "Could not insert private message sent info.", "", __LINE__, __FILE__, $sql_info);
   }

   $privmsg_sent_id = $db->sql_nextid();

   $sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
      VALUES ($privmsg_sent_id, '" . $bbcode_uid . "', '$pm_message')";

   if ( !$db->sql_query($sql, END_TRANSACTION) )
   {
      message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
   }

   // Add to the users new pm counter
   $sql = "UPDATE " . USERS_TABLE . "
      SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . time() . " 
      WHERE user_id = $pm_user_id";
   if ( !$status = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
   }      
}//end PM      


//Application successfull submit page

include($phpbb_root_path . 'includes/bbcode.'.$phpEx);


//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_FAQ);
init_userprefs($userdata);
//
// End session management
//


//
// Lets build a page ...
//
$page_title = $title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
   'body' => $tpl_file)
);

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
else {
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_FAQ);
init_userprefs($userdata);
//
// End session management
//

//
// Lets build a page ...
//
$page_title = "ERROR - Please Fill in all areas";
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
   'body' => 'ftw_app_error.tpl')
);

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
?>


ftw_app_form_successful.tpl
Code: Select all
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
   <tr>
      <td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></td>
   </tr>
</table>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
   <tr>
      <td height="33" class="row2"><span class="nav">
     <center>Thank You for applying to join FTW.  We have sent you a email with more details.</center>
 </td>
</table>


ftw_app_error.tpl
Code: Select all
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
   <tr>
      <td align="left" class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></td>
   </tr>
</table>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
   <tr>
      <td height="33" class="row2"><span class="nav">
     <center><br><br><font size='+3'><b>ERROR</b></font><br><br>Please press 'Back' and try again and fill in all areas</center>
     </span></td></tr></table>
Last edited by Knightkittens on Wed Oct 10, 2007 7:15 pm, edited 2 times in total.
Knightkittens
WR.net Apprentice
WR.net Apprentice
 
Posts: 14
Joined: Sun Jul 16, 2006 12:29 am

Re: phpbb2 inserting posts code error (need Help)

Postby Knightkittens » Tue Oct 09, 2007 8:06 pm

/bump

just a little bump for help
Knightkittens
WR.net Apprentice
WR.net Apprentice
 
Posts: 14
Joined: Sun Jul 16, 2006 12:29 am

phpbb2 inserting posts code error (need Help)

Postby Subxero » Tue Oct 09, 2007 9:31 pm

Fail a lot of code... and have mistakes on php..

there any source download ?

example
Code: Select all
$prof2 = $_POST["prof2"]
$whyjoin = $_POST["whyjoin"]
$prevguild = $_POST["prevguild"]
$preraidexp = $_POST["preraidexp"]
$additional = $_POST["additional"]
$friends = $_POST["friends"]
$xrealms = $_POST["xrealms"]
$alt1name = $_POST["alt1name"]
$alt1class = $_POST["alt1class"]
$alt1level = $_POST["alt1level"]
$alt2name = $_POST["alt2name"]
$alt2class = $_POST["alt2class"]
$alt2level = $_POST["alt2level"]
$alt3name = $_POST["alt3name"]
$alt3class = $_POST["alt3class"]
$alt3level = $_POST["alt3level"]
$submit = $_POST["submit"]

fail ; at end of every line...

Or tag_app_error.tpl is ftw_app_error.tpl
Last edited by Subxero on Tue Oct 09, 2007 9:48 pm, edited 1 time in total.
Subxero - Priest 70 Holy - Asphelt Knight Officer - Zul'jin Horde.
User avatar
Subxero
WR.net Artisan
WR.net Artisan
 
Posts: 234
Joined: Thu Jul 06, 2006 4:08 pm
Realm: Zul'jin (PvE) - US

Re: phpbb2 inserting posts code error (need Help)

Postby Knightkittens » Wed Oct 10, 2007 12:52 pm

yeah I somehow copied an incompleted work ill uploade the files with the source.

all those examples are incorcet as they didn't have ;
after each of the line [""]

From what I can tell the post Id is where it fails ftw_app_form_submit. its not regestering the post ID
Attachments
ftw_app.ace
source code
(7.75 KiB) Downloaded 91 times
Last edited by Knightkittens on Wed Oct 10, 2007 7:38 pm, edited 1 time in total.
Knightkittens
WR.net Apprentice
WR.net Apprentice
 
Posts: 14
Joined: Sun Jul 16, 2006 12:29 am


Return to General Code Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron