View Single Post
  #388  
Old 03-17-2005, 06:28 PM
morrow's Avatar
morrow morrow is offline
 
Join Date: Mar 2002
Location: NJ
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ChrisBaktis
form:

Code:
<?php

/*======================================================================*\
|| #################################################################### ||
|| # FORM TO THREAD/ FORUM/ PM/ EMAIL - Totally CUSTOMIZABLE FORMS    # ||
|| # Version 1.6 for vBulletin 3.x.x by Dr Erwin Loh                  # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000?2004 Dr Erwin Loh. All Rights Reserved.          # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| #################################################################### ||
\*======================================================================*/

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

$globaltemplates = array(
    'tc_tradepostform',
    'tc_tradepostformanswers'
);

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

globalize($_POST, array(
'normalanswer1' => STR,
'radioanswer1' => STR,
'radioanswer2' => STR,
'radioanswer3' => STR,
'radioanswer3other' => STR,
'answer1' => STR,
'answer2' => STR,
'answer3' => STR,
'longanswer1' => STR,
'action' => STR
));

// #######################################################################
// ######################## CUSTOMIZE VARIABLES ##########################
// #######################################################################

////////////////////////////////////////////////////////////////////////////////////////////////////
////// BEGIN CUSTOMIZATION BELOW////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//USERGROUPS ALLOWED
//You can add or remove usegroups that are ALLOWED to use this form by changing the numbers below in the array
////////////////////////////////////////////////////////////////////////////////////////////////////

if (!in_array($bbuserinfo['usergroupid'], array(2,5,6,9,13,15,16,17,19))) print_no_permission();

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//NAME OF THIS PHP FILE AND TEMPLATES - DO THIS BIT IF YOU ARE MAKING MORE FORMS!
//You can easily make more forms by just copying this file, renaming it, and modifying the variable in
//this file. You can keep the same templates for different forms. For more customization, you can
//use different templates, by renaming and modifying the templates.
////////////////////////////////////////////////////////////////////////////////////////////////////

// Name of this file
$phpfilename = "tc_tradepostform.php";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//CHOOSE WHETHER YOU WANT FORM TO BE POSTED IN A NEW THREAD, NEW POLL, REPLY TO EXISITING THREAD, PMed OR EMAILED
///////////////////////////////////////////////////////////////////////////////////////////////////

//ENABLE FORM TO BE POSTED - 1 = yes, 0 = no
$formforum = "1";

//FORUM TO POST NEW THREAD IN
$formforumid = "36";

//ENABLE POLL TO BE CREATED - 1 = yes, 0 = no
$formpoll = "0";
$formoption1 = "Yes";
$formoption2 = "No";

////////////////////////////////////////////////////////////////////////////////////////////////////

//ENABLE FORM TO REPLY TO EXISTING THREAD
$formreply = "0";

//EXISTING THREAD ID FOR FORM TO REPLY IN
$formreplythreadid = "12345";

//FORUM ID WHERE THE EXISTING THREAD IS IN
$formreplyforumid = "456";

////////////////////////////////////////////////////////////////////////////////////////////////////

//ENABLE FORM TO BE PMED - 1 = yes, 0 = no
$formpm = "0";

//USERID TO PM TO
$formpmid = "1";

////////////////////////////////////////////////////////////////////////////////////////////////////

//ENABLE FORM TO BE EMAILED - 1 = yes, 0 = no
$formemail = "0";

//EMAIL ADDRESS TO EMAIL TO
$formemailaddress = "youremail@yourforums.com";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//REDIRECT OPTIONS:
// 0 - thank you message
// 1 - redirect to post
// 2 - redirect to thread
// 3 - redirect to forum
// 4 - redirect to editpost to upload attachments
//
// Feel free to change the thank you message if you choose option 0
////////////////////////////////////////////////////////////////////////////////////////////////////

$redirectoption = "4";

$errormessage = "Thank you for submitting this form!"; //This is the thank you message

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//FORCE USER TO ANSWER ALL QUESTIONS - 1 = yes, 0 = no
////////////////////////////////////////////////////////////////////////////////////////////////////

$answerall = "0";

////////////////////////////////////////////////////////////////////////////////////////////////////
//TITLE OF FORM (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$formtitle = "Personal Trade Center - Post A Trade/Sale";

////////////////////////////////////////////////////////////////////////////////////////////////////
//PURPOSE OF FORM (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$formpurpose = "Use This Form To Post A Trade or Sale Between RST Members";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//RADIO BOX CHOICES : QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$radioquestion1 = "Is This A Trade Or Sale?";

// The following choices must NOT have quotation marks
$radiochoice1a = "Trade";
$radiochoice1b = "Sale";

////////////////////////////////////////////////////////////////////////////////////////////////////
//RADIO BOX CHOICES : QUESTION 2 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$radioquestion2 = "Insurance On Shipping";

// The following choices must NOT have quotation marks
$radiochoice2a = "Yes";
$radiochoice2b = "No";

////////////////////////////////////////////////////////////////////////////////////////////////////
//RADIO BOX CHOICES : QUESTION 3 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$radioquestion3 = "Delivery Confirmation";

// The following choices must NOT have quotation marks
$radiochoice3a = "Yes";
$radiochoice3b = "No";

////////////////////////////////////////////////////////////////////////////////////////////////////
//RADIO BOX CHOICES : QUESTION 4 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$radioquestion4 = "Who Is Sending First";

// The following choices must NOT have quotation marks
$radiochoice4a = "Me";
$radiochoice4b = "Trade Partner";
$radiochoice4c = "Same Time";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//NORMAL INPUT BOX : QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$normalquestion1 = "Trade/Sale Member Name #1";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//LONG TEXT AREA INPUT: QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$longquestion1 = "Please Post What Member #1 Will RECEIVE";

////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//NORMAL INPUT BOX : QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$normalquestion2 = "Trade/Sale Member Name #2";

////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//LONG TEXT AREA INPUT: QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$longquestion2 = "Please Post What Your Trade/Sale Partner WILL RECEIVE";

////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
//LONG TEXT AREA INPUT: QUESTION 1 (do not use quotation marks or you will get a parse error)
////////////////////////////////////////////////////////////////////////////////////////////////////

$longquestion3 = "Include Any Other Info Here";

////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////
////// END OF CUSTOMIZATION ////////////////////////////////////////////////////////////////////
/////  DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING!!! ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

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

// start navbar
$navbits = array(
    "$phpfilename?$session[sessionurl]" => $formtitle
);

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

if ($action=="submit") {

if ($answerall == "1") {
    if ($normalanswer1 == '' OR $radioanswer1 == '' OR $radioanswer2 == '' OR $radioanswer3 == '' OR $answer1 == '' OR $answer2 == '' OR $answer3 == '' OR $longanswer1 == '')
    {
    $errormessage = "$bbuserinfo[username], you need to answer every question!";
    eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
    exit();
    }
}

    eval('$formsend = "' . fetch_template('tc_tradepostformanswers') . '";');

    if ($formforum == "1") {
                    $DB_site->query("
                                INSERT INTO " . TABLE_PREFIX . "thread(title, lastpost, forumid, open, replycount,
                                postusername, postuserid, lastposter, dateline, iconid, visible, attach)
                                VALUES
                                        ('".addslashes(htmlspecialchars($bbuserinfo[username]))." / $normalanswer2', " . TIMENOW . ", $formforumid,
                                         1, 0, '" . addslashes($bbuserinfo['username']) . "', $bbuserinfo[userid],
                                         '" . addslashes($bbuserinfo['username']) . "', " . TIMENOW . ", 0, 1,
                                         0)
                        ");
                $thread['threadid'] = $DB_site->insert_id();
                $DB_site->query("
                        INSERT INTO " . TABLE_PREFIX . "post
                                (threadid, title, username, userid, dateline, pagetext, allowsmilie,
                                 showsignature, iconid, visible)
                        VALUES
                                ($thread[threadid], '".addslashes(htmlspecialchars($bbuserinfo[username]))." / $normalanswer2',
                                 '" . addslashes($bbuserinfo['username']) . "', $bbuserinfo[userid], " . TIMENOW . ",
                                 '" . addslashes($formsend) . "', 1, 1,
                                 0, 1)
                ");
                $post['postid'] = $DB_site->insert_id();
                $DB_site->query("
                                UPDATE " . TABLE_PREFIX . "thread
                                SET firstpostid = $post[postid]
                                WHERE threadid = $thread[threadid]
                        ");
                $DB_site->query("
                                UPDATE " . TABLE_PREFIX . "forum
                                SET replycount = replycount +  1,
                                threadcount = threadcount + 1,
                                lastpost = " . TIMENOW . ",
                                lastposter = '" . addslashes($bbuserinfo['username']) . "',
                                lastthread = '".addslashes(htmlspecialchars($bbuserinfo[username]))." /$normalanswer2',
                                lastthreadid = $thread[threadid]
                                WHERE forumid = $formforumid
                        ");
$forum[forumid] = $formforumid;
    }

    if ($formpoll == "1") {
              $DB_site->query("INSERT INTO " . TABLE_PREFIX . "poll (question,dateline,options,votes,active,numberoptions,timeout,multiple,public) VALUES ('".addslashes(htmlspecialchars($bbuserinfo[username]))." $formtitle'," . TIMENOW . ",'$formoption1|||$formoption2','" . addslashes("0|||0") . "',1,2,0,0,0)");
            $pollid = $DB_site->insert_id();
            $DB_site->query("UPDATE " . TABLE_PREFIX . "thread SET pollid = '".$pollid."' WHERE threadid = '".$thread[threadid]."'");
}

    if ($formreply == "1") {
      $DB_site->query("INSERT INTO post (postid,threadid,title,username,userid,dateline,pagetext,allowsmilie,showsignature,ipaddress,iconid,visible) VALUES (NULL,'$formreplythreadid','".addslashes(htmlspecialchars($bbuserinfo[username]))." $formtitle','".addslashes($bbuserinfo[username])."','$bbuserinfo[userid]','".time()."','" . addslashes($formsend) . "','1','1','0','0','1')");
      $DB_site->query("UPDATE thread SET replycount = replycount + 1, lastpost = " . TIMENOW . ", lastposter = '".addslashes($bbuserinfo[username])."' WHERE threadid = $formreplythreadid");
                      $DB_site->query("
                                UPDATE " . TABLE_PREFIX . "forum
                                SET replycount = replycount +  1,
                                lastpost = " . TIMENOW . ",
                                lastposter = '".addslashes(htmlspecialchars($bbuserinfo[username]))."',
                                lastthread = '" . addslashes($bbuserinfo['username']) . " $formtitle',
                                lastthreadid = $formreplythreadid
                                WHERE forumid = $formreplyforumid
                        ");
$forum[forumid] = $formreplyforumid;
    }

if ($formpm == "1") {
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "pmtext\n\t(fromuserid, fromusername, title, message, touserarray, iconid, dateline, showsignature)\nVALUES\n\t($bbuserinfo[userid], '" . addslashes($bbuserinfo['username']) . "', '".addslashes(htmlspecialchars($formtitle))."', '".addslashes(htmlspecialchars($formsend))."', '" . addslashes(serialize($tostring)) . "', 0, " . TIMENOW . ", 1)");
$pmtextid = $DB_site->insert_id();
$DB_site->query("INSERT INTO " . TABLE_PREFIX . "pm (pmtextid, userid, messageread) VALUES ($pmtextid, $formpmid, 0)");
$DB_site->shutdown_query("UPDATE " . TABLE_PREFIX . "user SET pmtotal=pmtotal+1, pmunread=pmunread+1 WHERE userid = $formpmid");
    }

    if ($formemail == "1") {
    vbmail($formemailaddress, $formtitle, $formsend);
    }

if ($redirectoption == "1") {
            $url = "showthread.php?$session[sessionurl]p=$post[postid]";
            eval(print_standard_redirect('redirect_postthanks'));
   exit();
}
if ($redirectoption == "2") {
            $url = "showthread.php?$session[sessionurl]t=$thread[threadid]";
            eval(print_standard_redirect('redirect_postthanks'));
   exit();
}
if ($redirectoption == "3") {
            $url = "forumdisplay.php?$session[sessionurl]f=$forum[forumid]";
        eval(print_standard_redirect('redirect_postthanks'));
   exit();
}
if ($redirectoption == "4") {
            $url = "editpost.php?do=editpost&$session[sessionurl]p=$post[postid]";
            eval(print_standard_redirect('redirect_postthanks'));
   exit();
}
   eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
   exit();
}
eval('print_output("' . fetch_template('tc_tradepostform') . '");');
?>
Form Template (I left out my custom skin template info)

Code:
<!-- main page contents -->

<form enctype="multipart/form-data" method="post" action="$phpfilename">
<input type="hidden" value="$userid" name="userid">
<input type="hidden" value="submit" name="action">

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="tcat" colspan="3">
		$formtitle
	</td>
</tr>


<!-- Sale or Trade Start -->
<tr>
	<td class="alt2" colspan="3"> <b><font color="#ff0000">$radioquestion1</font></b><br>
	<INPUT TYPE="radio" NAME="radioanswer1" value="$radiochoice1a"> <b>$radiochoice1a</b> <INPUT TYPE="radio" NAME="radioanswer1" value="$radiochoice1b"> <b>$radiochoice1b</b> </td>
</tr>
<!-- Sale or Trade End -->

<!-- Blank Line -->
<tr>
<td class="alt1" valign="middle" height="25"></td>
</tr>
<!-- Blank Line End-->


<!-- Member #1 Start -->
<tr>
	<td class="alt2" colspan="3"> 

	<b><font color="#ff0000">What will $bbuserinfo[username] get?</font></b><br>


<textarea rows="5" cols="70" name="longanswer1"></textarea>
</td>
</tr>
<!-- Member #1 End -->

<!-- Blank Line -->
<tr>
<td class="alt1" valign="middle" height="25"></td>
</tr>
<!-- Blank Line End-->


<!-- Member #2 Start -->
<tr>
	<td class="alt2" colspan="3"> <b><font color="#ff0000">Username of your trade/sale partner? (must be exact - please be careful)</font></b><br>
		


<input type="text" size="30" name="normalanswer2"><br><BR>


	<b><font color="#ff0000">$longquestion2</font></b><br>


<textarea rows="5" cols="70" name="longanswer2"></textarea>
</td>
</tr>
<!-- Member #2 End -->

<!-- Blank Line -->
<tr>
<td class="alt1" valign="middle" height="25"></td>
</tr>
<!-- Blank Line End-->

<!-- Insurance Start -->
<tr>
	<td class="alt2" colspan="3"> <b><font color="#ff0000"><b>$radioquestion2</b></font></b><br>
	<INPUT TYPE="radio" NAME="radioanswer2" value="$radiochoice2a"> <b>$radiochoice2a</b> <INPUT TYPE="radio" NAME="radioanswer2" value="$radiochoice2b"> <b>$radiochoice2b</b> </td>
</tr>
<!-- Insurance End End-->

<!-- Del Conf. Start -->
<tr>
	<td class="alt2" colspan="3"> <b><font color="#ff0000">$radioquestion3</font></b><br>
	<INPUT TYPE="radio" NAME="radioanswer3" value="$radiochoice3a"> <b>$radiochoice3a<b> <INPUT TYPE="radio" NAME="radioanswer3" value="$radiochoice3b"> <b>$radiochoice3b</b> </td>
</tr>
<!-- Del. Conf. End-->

<!-- Shipping Start -->
<tr>
	<td class="alt2" colspan="3"> <b><font color="#ff0000">$radioquestion4</font></b><br>
	<INPUT TYPE="radio" NAME="radioanswer4" value="$radiochoice4a"> <b>$radiochoice4a</b> <INPUT TYPE="radio" NAME="radioanswer4" value="$radiochoice4b"> <b>$radiochoice4b</b> <INPUT TYPE="radio" NAME="radioanswer4" value="$radiochoice4c"> <b>$radiochoice4c</b> </td>
</tr>
<!-- Shipping End-->

<!-- Blank Line -->
<tr>
<td class="alt1" valign="middle" height="25"></td>
</tr>
<!-- Blank Line End-->

<!-- Misc Info Start -->
<tr>
<td class="alt2" colspan="3"> 
<b><font color="#ff0000">$longquestion3</font></b><br>	
<textarea rows="5" cols="70" name="longanswer3"></textarea>
</td>
</tr>
<!-- Misc Info End -->

<tr>
<td valign="top">
<p align="center">
<input type="submit" value="Submit" name="submit" style="font-family: Verdana; font-size: 10pt" class="button"> 
<input type="reset" value="Reset" name="reset" style="font-family: Verdana; font-size: 10pt" class="button">
</p></td></tr>
</table>
</td>
</tr>
</table>

</font>

</form>

<!-- / main page contents -->
Answer Template

Code:
This $radioanswer1 Is Between: $bbuserinfo[username] & $normalanswer2

Type Of Transaction: $radioanswer1

$radioquestion2: $radioanswer2

$radioquestion3: $radioanswer3

$radioquestion4: $radioanswer4

-------------------------------------------------

$bbuserinfo[username] gets:
$longanswer1

$normalanswer2 gets:
$longanswer2

-------------------------------------------------

Misc Information:
$longanswer3
The answer template has bb code because I have this directed to post to a forum.
Chris,

Thank you so much for your time and effort. I really appreciate this. I'm going to give this a shot later tonight.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01282 seconds
  • Memory Usage 1,912KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_quote
  • (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