TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 448
  • Total: 448

Generic Application Form

Started by JPDeni, May 23, 2009, 11:04:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

maviel

i tried that i want this to be shown as a post on the forums when an application been made not in the default "question" thing.

maviel

it seems not work for me. i get some stuff working but all Text is not being posted on the forums. Anyone know why?
                                                                global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info;

// Guests can't fill out the form
if ($ID_MEMBER == 0)
    echo 'Fel! Du mÃ¥ste vara inloggad innan du kan göra en ansökan till Valhalla Legion.';
else {

require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');


// CONFIGURATION SECTION

$intro_form = "Även om detta applikations system inte är som alla andras gillens så vet vi på Valhalla Legion att DU tar din tid och skriver ner nogranna svar på de frågor som kommer upp eftersom detta kommer vara vårat första intryck på dig som person.";
$thanks_text = "Tack för din ansökan till Valhalla Legion. Din ansökan har nu skickats till alla officerare i guildet via E-Mail samt så har denna ansökan kommit upp på forumet och kommer granskas innom 24 timmar. Har du inte fått ett svar innom 48 timmar så får du kontakta någon av officerarna i guildet som är Knax eller Nahiag.";

// Define your fields. All of these values need to be defined, even if they are empty.
// The fields will be displayed in the order in which they are listed in the array.
// $fielddef =
//   array(
//     array(
//       'caption' =>      "", // caption to be displayed on the form. Can include symbols and spaces.
//       'name' =>         "", // a unique name for the field. No symbols or spaces
//       'type' =>         "", // text, radio, select, checkbox, textarea, heading
//       'options' =>      "", // for radio and select fields. List in order you wish them to appear, separated by commas; for checkboxes, it's the value to be saved and displayed next to the box
//       'defaultvalue' => "", // the default value for the field. Can be a variable or text. Be sure to enclose text in quotation marks
//       'required' =>     0   // 0 or 1 -- use 1 if the field must be filled out. use 0 if it's optional; never set a checkbox to be required
//     ),
//   );

$fielddef =
array(
array(
'caption' =>      "Personlig Information",
'name' =>         "Personlig Informaition",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Namn",
'name' =>         "Namn",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
),
array(
'caption' =>      "Ã…lder",
'name' =>         "Ã…lder",
'type' =>         "select",
'options' =>      "13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40+",
'defaultvalue' => "18",
'required' =>     0
), 
array(
'caption' =>      "Kille/Tjej",
'name' =>         "Gen",
'type' =>         "radio",
'options' =>      "Kille,Tjej",
'defaultvalue' => "",
'required' =>     0
), 
array(
'caption' =>      "Berätta Lite om dig själv",
'name' =>        "Lite om mig själv",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Karraktärs Information",
'name' =>         "Karraktärs Information",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                array(
'caption' =>      "Karraktärs namn",
'name' =>         "charname",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
),
            array(
'caption' =>      "Level",
'name' =>         "charlvl",
'type' =>         "select",
'options' =>      "80,79,78,77,76",
'defaultvalue' => "80",
'required' =>     0
), 
              array(
'caption' =>      "Ras",
'name' =>         "charrace",
'type' =>         "select",
'options' =>      "Dranei,Dwarf,Human,Night Elf,Gnome",
'defaultvalue' => "Dranei",
'required' =>     0
), 
              array(
'caption' =>      "Klass",
'name' =>         "charclass",
'type' =>         "select",
'options' =>      "Death Knight,Druid,Hunter,Mage,Paladin,Priest,Rogue,Shama,Warlock,Warrior",
'defaultvalue' => "Death Knight",
'required' =>     0
),
              array(
'caption' =>      "Primär Spec",
'name' =>         "charspec",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
),
                array(
'caption' =>      "Secondär Spec",
'name' =>         "Secondär Spec",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
                ),
                                         array(
'caption' =>      "Respecar du din klass om vi ber om det?",
'name' =>         "Respecar du din klass om vi ber om det?",
'type' =>         "radio",
'options' =>      "Ja,Nej",
'defaultvalue' => "",
'required' =>     0
), 
                array(
'caption' =>      "/Played",
'name' =>         "/Played",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
),
                array(
'caption' =>      "Armory Länk",
'name' =>         "Armory Länk",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0   
),
           
            array(
'caption' =>      "Är det du själv som har levlat upp din character?",
'name' =>         "Levlat upp gubben själv",
'type' =>         "radio",
'options' =>      "Ja,Nej",
'defaultvalue' => "",
'required' =>     0
), 
 
            array(
'caption' =>      "Vilka dagar/tider kan du raida pÃ¥ (Va specifik)",
'name' =>         "Vilka dagar/tider kan du raida pÃ¥ (Va specifik)",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                array(
'caption' =>      "Raid FrÃ¥gor",
'name' =>         "Raid FrÃ¥gor",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                  array(
'caption' =>      "Raidade du Classic? Hur lÃ¥ngt kom du?",
'name' =>         "Raidade du Classic? Hur lÃ¥ngt kom du?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                      array(
'caption' =>      "Raidade du TBC? Hur lÃ¥ngt kom du?",
'name' =>         "Raidade du TBC? Hur lÃ¥ngt kom du?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                      array(
'caption' =>      "Vad är din nuvarande RAID progress i WOTLK? (Va specifik)",
'name' =>         "Vad är din nuvarande RAID progress i WOTLK? (Va specifik)",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                        array(
'caption' =>      "Vad gör dig till en bra medspelare i raids?",
'name' =>         "Vad gör dig till en bra medspelare i raids?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
                array(
'caption' =>      "Är du en klicker?",
'name' =>         "Är du en klicker?",
'type' =>         "radio",
'options' =>      "Ja,Nej,Lite av bÃ¥da",
'defaultvalue' => "",
'required' =>     0
), 
                array(
'caption' =>      "Har du en FUNGERANDE mic?",
'name' =>         "Har du en FUNGERANDE mic?",
'type' =>         "radio",
'options' =>      "Ja,Nej",
'defaultvalue' => "",
'required' =>     0
), 
                            array(
'caption' =>      "Guild Relaterade FrÃ¥gor",
'name' =>         "Guild Relaterade FrÃ¥gor",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                            array(
'caption' =>      "Är du med i ett guild? isf vilket?",
'name' =>         "Är du med i ett guild? isf vilket?",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                      array(
'caption' =>      "Om JA pÃ¥ frÃ¥gan över varför vill du lämna guildet?",
'name' =>         "Om JA pÃ¥ frÃ¥gan över varför vill du lämna guildet?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                        array(
'caption' =>      "Om NEJ pÃ¥ frÃ¥gan varför har du lämnat/blivit kickad frÃ¥n guildet?",
'name' =>         "Om NEJ pÃ¥ frÃ¥gan varför har du lämnat/blivit kickad frÃ¥n guildet?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                                                array(
'caption' =>      "Vad kan DU erbjuda Valhalla Legion som spelare?",
'name' =>         "Vad kan DU erbjuda Valhalla Legion som spelare?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                                    array(
'caption' =>      "Vad kan Valhalla Legion erbjuda DIG som spelare?",
'name' =>         "Vad kan Valhalla Legion erbjuda DIG som spelare?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                                                array(
'caption' =>      "Finns det nÃ¥gon som kan Rekomendera dig i Valhalla Legion?",
'name' =>         "Finns det nÃ¥gon som kan Rekomendera dig i Valhalla Legion?",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
                                        array(
'caption' =>      "Ãâ€"vrigt",
'name' =>         "Ãâ€"vrigt",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
               
           
            array(
'caption' =>      "Kan du nÃ¥got roligt skämt?",
'name' =>         "Kan du nÃ¥got roligt skämt?",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
                ),
           
               
);
       



//send the application by email?
$enable_email=false;

// email address of recruitment staff member
$email_address='';

//post the application on forum?
$enable_post=true;

//board id to which the application should be posted
$board_id=13.0;


//END OF CONFIGURATION SECTION
////////////////////////////////////////////////////////////////////////////////////////////


$show_form= 'true';
if (isset($_REQUEST['submitted'])) {  // Handle the form
// Check required fields
$errors = array(); //Initialize error array

foreach ($fielddef as $field)
if (empty($_REQUEST[$field['name']]) && ($field['required'] == 1)){ $errors[] = $field['name']; }

// There's at least one field missing
if (isset($errors[0])) {
foreach ($_REQUEST as $key => $value)
$fieldvalue[$key] = $value;
}
else { // all is well
 
$show_form='false';

if ($enable_email) {  // email an application
$subject = 'Application';
$body = '';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$body .= $field['caption'] . '
';
else
$body .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '
';
}
mail($email_address, $subject, $body,"From: " . $user_info['email']);
}

if ($enable_post) {  //create new forum post with application

$postbody = 'Ansökningen har gjorts av ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] .  '<br /><br />';
else
$postbody .=  $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}

$msgOptions = array(
'id' =>  0 ,
'subject' => '[OAVSLUTAT] ' . $_REQUEST['charlvl'] . ' ' . $_REQUEST['charspec'] . ' ' . $_REQUEST['charclass'] . ' ' . $_REQUEST['charname']  ,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);
createPost($msgOptions, $topicOptions, $posterOptions);
}
// Text for thank you page
echo $thanks_text;
}
}
else {
foreach ($fielddef as $field) {
$fieldvalue[$field['name']] = $field['defaultvalue'];
}
}

// Looks like you want the form,
if ($show_form == 'true') {
echo $intro_form . "<br>";
if (isset($errors[0])) { echo '<div style="color: red;">Du har inte fyllt i alla fält med en stjärna *.</div>';  }

echo '
<form action="' . $scripturl . '?page='  . $_GET['page'] . '" method="post">
<INPUT name="submitted" type="hidden" value="TRUE" />
        <table style="margin-left:auto; margin-right:auto;">';

$bg = 'windowbg2';

foreach ($fielddef as $field) {
// Headings have their own type of display
if ($field['type'] == 'heading') {
echo '
<TR>
<TD colspan="2" style="text-align: center; text-decoration: underline;"><b>' .
$field['caption'] . '</b>
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':
</TD>
<TD align="left">';

// Go through each field type
if ($field['type'] == 'text') {
echo '<INPUT name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" />';
}
elseif ($field['type'] == 'radio') {
$options = explode(',',$field['options']);
foreach ($options as $option) {
echo '<INPUT TYPE="RADIO" NAME="' . $field['name'] . '" VALUE="'. $option . '"';
if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' CHECKED'; }
echo '>' . $option . ' ';
}
}
elseif ($field['type'] == 'checkbox') {
echo '<INPUT TYPE="CHECKBOX" NAME="' . $field['name'] . '" VALUE="'. $field['options'] . '"';
if (isset($fieldvalue[$field['name']]) && ($fieldvalue[$field['name']]==$field['options'])) { echo ' CHECKED'; }
echo '>' . $field['options'];   
}
elseif ($field['type'] == 'select') {
echo '<SELECT name="' . $field['name'] . '" />';
$options = explode(',',$field['options']);
foreach ($options as $option) {
echo '<OPTION value="' . $option . '"';
if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' selected'; }
echo '>' . $option . '</OPTION>';
}
echo '</SELECT>';
}   
elseif ($field['type'] == 'textarea') {
echo '<TEXTAREA name="' . $field['name'] . '" rows="4" cols="40">';
echo $fieldvalue[$field['name']];
echo '</' . 'TEXTAREA>';
}

// Finish off the row
echo '
</TD>
</TR>';
}

// Set up the alternating colors for the next row
($bg == 'windowbg2') ? $bg = 'windowbg' : $bg = 'windowbg2';
}

echo '
<TR class ="' . $bg . '">
<TD colspan="2" align="center">
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset">
</TD>
</TR>
</TABLE>
</form>';
}
}


JPDeni

Quoteall Text is not being posted on the forums.

Can you be more specific? What is and what is not being posted? An example would help to narrow things down.

maviel

it is only the class, name, played, that is posted i think there is a leak somewer i get this error:

8: Undefined index: Kan du något roligt skämt?
File: /hsphere/local/home/kenta81/valhallalegion.se/Themes/default/TPortal.template.php (main sub template - eval?)
Line: 363

And befor i did get an error from tpshout and disabled it and got this one above instead.


JPDeni

I don't know if this is the problem or not, but the "name" for each item should be just one word and it would probably be best if you used only letters that are in English. As the instructions say

Quote//       'name' =>         "", // a unique name for the field. No symbols or spaces

The "name" doesn't show on your form or on the forum entry. It's just something so the script can tell the different fields apart. It can literally be anything, except that you can't use spaces or symbols.

maviel

i got it working now, my bad  :idiot2:.

I never got an answer if i could fix the code so i could get the:
'type' =>         "heading",

Bolded on the forums after so it looks like this:

Header Name
question 1
question 2
question 3

Header Name2
question 1
question 2
question 3

i believe it is this code i should change somewere:
$postbody = 'Ansökningen har gjorts av ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] .  '<br /><br />';
else
$postbody .=  $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}

$msgOptions = array(
'id' =>  0 ,
'subject' => '[OAVSLUTAT] ' . $_REQUEST['charlvl'] . ' ' . $_REQUEST['charspec'] . ' ' . $_REQUEST['charclass'] . ' ' . $_REQUEST['charname']  ,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);


Hairy

Wow this is a really good form, will have to play with it asap.

Thanks JPDeni  8)


JPDeni

Looks like I had missed the question that maviel asked.

Yes, that's the place you would alter it. Change


if ($field['type'] == 'heading')
$postbody .= $field['caption'] .  '<br /><br />';


to


if ($field['type'] == 'heading')
$postbody .= '[b]' . $field['caption'] .  '[/b]<br /><br />';


EasyRider

ÃŽâ€"i JPDeni..!   :)

Very useful  script!

Is possible to add  an option in specific board/topics  so my members can they add an review and posted in the same topic..?

I mean somthing like button in post reply area.

Is that very difficult ..?  ???

SMF  1.1.11 / TinyPortal v1.0 beta 4 /default theme

JPDeni

QuoteIs possible to add  an option in specific board/topics  so my members can they add an review and posted in the same topic..?

I'm not sure what you mean.

Are you asking if this form can be part of a topic on the forum? If that's what you're asking, I would say that it is conceivably possible, but I wouldn't have any idea of how to do it. You could probably be able to adapt it so that the responses are saved in another database table and then displayed with the article. Or possibly you could put it in a block to appear above a board and then have the reviews below it. But I don't know of a way to add programming to a post in a topic.

But possibly you mean something else. :) If so, I'll need you to try to reword your question.

This website is proudly hosted on Crocweb Cloud Website Hosting.