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: 413
  • Total: 413

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.

Bloodlvst

So I finally got around to actually putting this into practice!
But I'm having a problem, it still makes everything bold, but I want each response to be indented and bulleted. It posts the code itself, but doesn't cause it to appear correctly. If I click modify and preview, it's okay...it seems like something from the form to the post is going awry. Any ideas?

Just in case it helps, the line in question is:
$postbody .=  '[list][b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';

I should also note that if anyone can help me figure out how to make them numbered like how RaXavier did, that would be awesome. :)

global $sourcedir, $context, $scripturl, $user_info;
///// ZP Edit - Globals below replaced by the above
//global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Generic Application Form
// Originally created by JPDeni, TinyPortal Coding Goddess, reference the topic below:
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
//
// Edited on 6 June, 2010 by ZarPrime to work with SMF 2.0 RC3 and TinyPortal 1.0 beta 5 (Polls not enabled in this version)

// Guests can't fill out the form
if ($context['user']['id'] == 0)
    echo 'You must have an account on our site before you can apply.';
else {

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


// CONFIGURATION SECTION

   $intro_form = "So you've decided you want to join The Angels Of Armageddon. Great! Just keep the following in mind when applying:<br><br><b>1.</b> Be involved in the forums and be active on the server as much as possible. This shows us that you're an active part of the community and are serious about joining, and will help your application more than you might think!<br><b>2.</b> Having a mic is a requirement to join. We may be willing to make exceptions for extreme cases, and you can make your case in the comments of your app.<br><br><b>Approval Process</b>:<br>Upon posting your application, a forum post will be made in the Applications Section of the board. In your post, anyone may comment and/or vote, though we will only count votes from members, and if we look for input outside of the clan, only our regulars will be taken into consideration. It's best to have been playign with us long enough that we know who you are, it's hard to want you to join us if we don't know you.<br><br>Once your application has been received, you must garner a 'yes' vote from at least 60% of the Joint Chiefs Of Staff. At that point your status as a member will be either accepted or rejected by Bloodlvst (very rarely will you actually be rejected), and you will officially be a member and be given tags. You may not wear tags until all of this has occured. <br>";
   $thanks_text = "Thanks for applying! You can check out the progress of your application in the Applications Section.";

// 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' =>      "Name On Server",
            'name' =>         "nickname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Real Name",
            'name' =>         "realname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Location",
            'name' =>         "location",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),         
         array(
            'caption' =>      "Age",
            'name' =>         "age",
            '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' => "16",
            'required' =>     1
         ),
         array(
            'caption' =>      "Ping On Server",
            'name' =>         "ping",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),         
         array(
            'caption' =>      "Do you have a mic?",
            'name' =>         "mic",
            'type' =>         "select",
            'options' =>      "No,Yes",
            'defaultvalue' => "No",
            'required' =>     1
         ),     
         array(
            'caption' =>      "Why do you want to join?",
            'name' =>       "joinreason",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1
         ),
         array(
            'caption' =>      "Tell us a bit about yourself",
            'name' =>         "bio",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),           
         array(
            'caption' =>      "Any other comments?",
            'name' =>         "comments",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),
         array(
            'caption' =>      "Did a member invite you?",
            'name' =>         "invite",
            'type' =>         "radio",
            'options' =>      "Yes,No",
            'defaultvalue' => "",
            'required' =>     1 
         ),
      );
//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;
//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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
foreach ($fielddef as $field) {
// Now we aren't going to print the headings or the subject in the post
if ($field['type'] == 'heading' || $field['name'] == 'subject')
echo '
<br />';
else
$postbody .=  '[list][b]' . $field['caption'] . '[/b][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' =>  0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// Use the one below if poster does enter subject
//'subject' => ($_REQUEST['subject']),
'body' => ($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;">Please fill in all fields with an asterisk (*).</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;">' .
$field['caption'] . '
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="left">';
              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="5" cols="80">';
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>';
}
}


Freddy

Remove the extra 'list' from your code :

Change...

$postbody .=  '[list][b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';

To this :

$postbody .=  '[list][b]' . $field['caption'] . '[/b][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';

And see if that works.

Bloodlvst

Thanks Freddy, didn't notice that. Unfortunately it didn't work though :(



Like I said, if I hit modify, and don't change anything, it will be normal, but I'd rather it just work when someone applies. :)

Freddy

What are your SMF and TP versions Mr Bloodlvust ?

Bloodlvst

Freddy, I'm rocking SMF 2.0 RC4 and TP 1.0 RC1

Freddy

OK yeah, I am getting the same results here.  Leave it with me a while.

Freddy

See if this works, it seems okay here.  After taking a proper look, it was the way 'list' was getting used.  I should have suggested removing the first one, not the second doh !


global $sourcedir, $context, $scripturl, $user_info;
///// ZP Edit - Globals below replaced by the above
//global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Generic Application Form
// Originally created by JPDeni, TinyPortal Coding Goddess, reference the topic below:
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
//
// Edited on 6 June, 2010 by ZarPrime to work with SMF 2.0 RC3 and TinyPortal 1.0 beta 5 (Polls not enabled in this version)

// Guests can't fill out the form
if ($context['user']['id'] == 0)
    echo 'You must have an account on our site before you can apply.';
else {

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


// CONFIGURATION SECTION

   $intro_form = "So you've decided you want to join The Angels Of Armageddon. Great! Just keep the following in mind when applying:<br><br><b>1.</b> Be involved in the forums and be active on the server as much as possible. This shows us that you're an active part of the community and are serious about joining, and will help your application more than you might think!<br><b>2.</b> Having a mic is a requirement to join. We may be willing to make exceptions for extreme cases, and you can make your case in the comments of your app.<br><br><b>Approval Process</b>:<br>Upon posting your application, a forum post will be made in the Applications Section of the board. In your post, anyone may comment and/or vote, though we will only count votes from members, and if we look for input outside of the clan, only our regulars will be taken into consideration. It's best to have been playign with us long enough that we know who you are, it's hard to want you to join us if we don't know you.<br><br>Once your application has been received, you must garner a 'yes' vote from at least 60% of the Joint Chiefs Of Staff. At that point your status as a member will be either accepted or rejected by Bloodlvst (very rarely will you actually be rejected), and you will officially be a member and be given tags. You may not wear tags until all of this has occured. <br>";
   $thanks_text = "Thanks for applying! You can check out the progress of your application in the Applications Section.";

// 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' =>      "Name On Server",
            'name' =>         "nickname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Real Name",
            'name' =>         "realname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Location",
            'name' =>         "location",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),         
         array(
            'caption' =>      "Age",
            'name' =>         "age",
            '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' => "16",
            'required' =>     1
         ),
         array(
            'caption' =>      "Ping On Server",
            'name' =>         "ping",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),         
         array(
            'caption' =>      "Do you have a mic?",
            'name' =>         "mic",
            'type' =>         "select",
            'options' =>      "No,Yes",
            'defaultvalue' => "No",
            'required' =>     1
         ),     
         array(
            'caption' =>      "Why do you want to join?",
            'name' =>       "joinreason",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1
         ),
         array(
            'caption' =>      "Tell us a bit about yourself",
            'name' =>         "bio",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),           
         array(
            'caption' =>      "Any other comments?",
            'name' =>         "comments",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),
         array(
            'caption' =>      "Did a member invite you?",
            'name' =>         "invite",
            'type' =>         "radio",
            'options' =>      "Yes,No",
            'defaultvalue' => "",
            'required' =>     1 
         ),
      );
//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;
//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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
$fieldCounter = 0;
foreach ($fielddef as $field) {
$fieldCounter++;
// Now we aren't going to print the headings or the subject in the post
if ($field['type'] == 'heading' || $field['name'] == 'subject')
echo '
<br />';
else
$postbody .=  $fieldCounter . '. [b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' =>  0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// Use the one below if poster does enter subject
//'subject' => ($_REQUEST['subject']),
'body' => ($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;">Please fill in all fields with an asterisk (*).</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;">' .
$field['caption'] . '
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="left">';
              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="5" cols="80">';
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>';
}
}

Bloodlvst

Thanks a ton Freddy! Works perfectly!

You da man! :D

NCSurfer

Thanks Freddy for the assistance. I do have an issue though. When I submit the form, the Thank you page does not show as well as the board I chose does not get a post of the form in it.

Using;
    Powered by SMF 2.0 RC5 | SMF © 2006â€"2011, Simple Machines LLC
    TinyPortal 1.0 RC1 | © 2005-2010 BlocWeb
    XHTML
    RSS
    WAP2
    Day Relax by Skinmod

And here is the code;
global $sourcedir, $context, $scripturl, $user_info;
///// ZP Edit - Globals below replaced by the above
//global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Generic Application Form
// Originally created by JPDeni, TinyPortal Coding Goddess, reference the topic below:
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
//
// Edited on 6 June, 2010 by ZarPrime to work with SMF 2.0 RC3 and TinyPortal 1.0 beta 5 (Polls not enabled in this version)

// Guests can't fill out the form
if ($context['user']['id'] == 0)
    echo 'You must be registered on our site before you can sign up for Horse Camp.';
else {

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


// CONFIGURATION SECTION

   $intro_form = "So you've decided you would like to attend Six Star Stables Horse Camp this summer. That is Great News! Just keep the following in mind when signing up:<br><br>
<b>1.</b> You will be required to HAVE A GREAT WEEK and be prepared to learn about horses. <br/><br/>
<b>2.</b>We will have barn projects that all the kids will participate in. <br><br>
We work this camp around the campers need to not only learn about a Horse Farm but also discipline, confidence, focus and FUN!<br> Please fill out all the fields in the Sign Up Form below. This way we will be able to get a good idea of who you are prior to meeting you for the first time.<br><br> ";

   $thanks_text = "Thanks for signing up for Horse Camp! One of our Staff members will be getting in touch with you soon. Also, please check back for NEWS about the barn on the forums.<br><br>
Thank You again. <br>
Six Star Stables Staff";

// 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' =>      "Name On The Website",
            'name' =>         "nickname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Real Name",
            'name' =>         "realname",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),
         array(
            'caption' =>      "Location",
            'name' =>         "location",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),         
         array(
            'caption' =>      "Age",
            'name' =>         "age",
            'type' =>         "select",
            'options' =>      "6,7,8,9,10,11,12,13,14,15,16+",
            'defaultvalue' => "10",
            'required' =>     1
         ),
         array(
            'caption' =>      "Phone Number",
            'name' =>         "phonenum",
            'type' =>         "text",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),         
         array(
            'caption' =>      "Is phone best means of contact?",
            'name' =>         "phonecont",
            'type' =>         "select",
            'options' =>      "No,Yes",
            'defaultvalue' => "Yes",
            'required' =>     1
         ),     
         array(
            'caption' =>      "Why would you like to attend Horse Camp?",
            'name' =>       "joinreason",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1
         ),
         array(
            'caption' =>      "Tell us a bit about yourself",
            'name' =>         "bio",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     1 
         ),           
         array(
            'caption' =>      "Any other comments?",
            'name' =>         "comments",
            'type' =>         "textarea",
            'options' =>      "",
            'defaultvalue' => "",
            'required' =>     0 
         ),
         array(
            'caption' =>      "Did a Barn Member invite you?",
            'name' =>         "invite",
            'type' =>         "radio",
            'options' =>      "Yes,No",
            'defaultvalue' => "",
            'required' =>     1 
         ),
      );
//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=4.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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
$fieldCounter = 0;
foreach ($fielddef as $field) {
$fieldCounter++;
// Now we aren't going to print the headings or the subject in the post
if ($field['type'] == 'heading' || $field['name'] == 'subject')
echo '
<br />';
else
$postbody .=  $fieldCounter . '. [b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' =>  0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// Use the one below if poster does enter subject
//'subject' => ($_REQUEST['subject']),
'body' => ($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;">Please fill in all fields, those with an asterisk are required(*).</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;">' .
$field['caption'] . '
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="left">';
              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="5" cols="80">';
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>';
}
}


Thanks for any help.

ZarPrime

NCSurfer,

Since I see you on, let's try a couple of things.  First of all,

Code (Find) Select

$board_id=4.0;

and
Code (Replace With) Select

$board_id=4;


and see if that fixes the issue with the topic being posted.

Secondly, your $thanks_text probably needs to be edited so that it's all on one line though I might be able to check this and see what's going on with that.

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.