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,911
  • Total Topics: 21,307
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 362
  • Total: 363
  • tino

[Done!] Join Us! form

Started by mebymyself, October 19, 2006, 08:10:13 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

durgia

wow... I deserve a smack in the head.... that is so simple!

I spent a fair bit of time trying to get rid of the code and never even thought once to make 2 separate pieces ...


thank you!

Xarcell

Quote from: Shaktii on February 09, 2009, 09:38:40 PM
HI all,

I need some adivce, I got this script working a treat thanks very much, however I get this error on every submit:

"Connection Problems
Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later."

It does not even reach the Thank You article, however it is adding the posts and emailing me the applications.

I have not altered the code other than simple text and email address, so no point in pasting it all again :)

Cheers


I've had similar problems, due to extra security provided by the host. Not saying that is the problem here, but with dreamhost I have to remove the extra security to my domains because it's blocks certain characters in the session within the URL.

Inny

#312
I dont know if anyone else is interested in adding reCaptcha in the form but im trying to add it because im having the form visible by guests because i dont want people registering for just a form.

Providing that you already have an account with reCaptcha and already having reCaptcha for SMF installed you get the following code from reCaptcha's site:


This is the code to display reCaptcha:
require_once('recaptchalib.php');
$publickey = "..."; // you got this from the signup page
echo recaptcha_get_html($publickey);



This is the code to validate reCaptcha:
require_once('recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
  die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
       "(reCAPTCHA said: " . $resp->error . ")");
}


Any help in which part to put the code in JPDeni's form will be greatly appreciated. Im having problems with the validation part of the code.

JPDeni

It would go after


if (isset($_REQUEST['submitted'])) {  // Handle the form


I don't know anything about the code, though, so I can't help any more than that.

Inny

Works like a charm, thanks again.

On a side note the recaptcha box shows in the top of the page. Thats how it is currently.


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


If i move

echo recaptcha_get_html($publickey);

i either get a PHP error or not correct validation of the words. Is there any way to make the form appear first? I believe its something to do with the echo' being after the echo for the recaptcha but putting that echo before causes PHP error.

Adding a sampe of my code:
global $sourcedir, $user_info, $context ;

require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
require_once($sourcedir .'/recaptchalib.php');
$publickey = "........."; // you got this from the signup page





// CONFIGURATION SECTION

$intro_form = "<center><h4><font color=red>Even if this is nothing like the normal Applications that you make a post and have to be well written, we still demand that every field that requires a written answer to be well written. </font></h4> </center><br>";   // Can include html

$thanks_text = "<center><h3><font color=red>Thanks for applying. Your application has been submitted successfully. We'll review your application and get back to you.</h3></font></center>"; // what is displayed after the form is submitted

// 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' =>      "Email:",
      'name' =>         "charemail",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
  ),
    array(
      'caption' =>      "Character Info:",
      'name' =>         "heading1",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
array(
      'caption' =>      "Character Name:",
      'name' =>         "charname",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Lever:",
      'name' =>         "charlevel",
      'type' =>         "select",
      'options' =>      "70,71,72,73,74,75,76,77,78,79,80",
      'defaultvalue' => "70",
      'required' =>     1
    ),
    array(
      'caption' =>      "Race",
      'name' =>         "charrace",
      'type' =>         "select",
      'options' =>      "Orc,Undead,Troll,Tauren,Blood Elf",
      'defaultvalue' => "Orc",
      'required' =>     1
    ),
array(
      'caption' =>      "Class:",
      'name' =>         "charclass",
      'type' =>         "select",
      'options' =>      "Druid,Hunter,Mage,Paladin,Priest,Rogue,Shaman,Warlock,Warrior,Death Knight",
      'defaultvalue' => "Druid",
      'required' =>     1
    ),
array(
      'caption' =>      "Days played:",
      'name' =>         "charplayed",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Profession 1:",
      'name' =>         "prof1",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
array(
      'caption' =>      "Profession 2:",
      'name' =>         "prof2",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
   array(
      'caption' =>      "How are you speced?:",
      'name' =>         "charspec",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Why you speced this way:",
      'name' =>         "specinfo",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "What are you class important stats:",
      'name' =>         "specstats",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Are you willing to respec for the Guild?:",
      'name' =>         "guildspec",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "No",
      'required' =>     1
    ),
array(
      'caption' =>      "Do you have any other Characters?:",
      'name' =>         "otherchars",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Armory Link:",
      'name' =>         "armorylink",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Achievement Points:",
      'name' =>         "achievementpoints",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "About You:",
      'name' =>         "heading2",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Age",
      'name' =>         "charage",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
   array(
      'caption' =>      "Sex:",
      'name' =>         "chargender",
      'type' =>         "select",
      'options' =>      "Male,Female,Yes Please,No Thanks",
      'defaultvalue' => "Yes Please",
      'required' =>     0
    ),
   array(
      'caption' =>      "Are You Emo?:",
      'name' =>         "charemo",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "Yes",
      'required' =>     0
    ),
    array(
      'caption' =>      "Country",
      'name' =>         "charcountry",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Why we should pick you?:",
      'name' =>         "guildpick",
      'type' =>         "textbox",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
   array(
      'caption' =>      "Previous Guilds and why you left?:",
      'name' =>         "guildleave",
      'type' =>         "textbox",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
   array(
      'caption' =>      "Do you have Ventrilo and Mic?:",
      'name' =>         "ventinfo",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "No",
      'required' =>     0
    ),
   array(
      'caption' =>      "Are you vocal in Ventrilo?:",
      'name' =>         "ventvocal",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "No",
      'required' =>     0
    ),
   array(
      'caption' =>      "Have you read the General Guild Rules?:",
      'name' =>         "guildrules",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "No",
      'required' =>     0
    ),
   array(
      'caption' =>      "We expect our members to be familiar with forums. Is this something you are used to?:",
      'name' =>         "charforum",
      'type' =>         "select",
      'options' =>      "Yes,No,Sometimes",
      'defaultvalue' => "No",
      'required' =>     0
    ),
  array(
      'caption' =>      "What can we expect from you, and what do you expect in return?",
      'name' =>         "charexpect",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
  array(
      'caption' =>      "Describe your Connection. Last Disconnect?",
      'name' =>         "coninfo",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
  array(
      'caption' =>      "Describe your PC Specifications:",
      'name' =>         "pcinfo",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
  array(
      'caption' =>      "UI Print Screen:",
      'name' =>         "uiinfo",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
  array(
      'caption' =>      "Can anyone or anything interfere your online gaming?",
      'name' =>         "interf",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "Yes",
      'required' =>     0
    ),
  array(
      'caption' =>      "If Yes describe:",
      'name' =>         "interfinfo",
      'type' =>         "textbox",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),

);



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

// email address of recruitment staff member
$email_address='grkronos@gmail.com';

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

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


//END OF CONFIGURATION SECTION




$show_form= 'true';
if (isset($_REQUEST['submitted'])) {  // Handle the form

require_once($sourcedir .'/recaptchalib.php');
$privatekey = "..........";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
  fatal_lang_error('visual_verification_failed', false);
}
else




// 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 = 'Enrollment Application';
  $body = 'Enrollment application has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . '
              ';
      foreach ($fielddef as $field) {
        $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 = 'Enrollment application has been made by ' . $context['user']['name'] .'<br /><br/>';
  foreach ($fielddef as $field) {
        if ($field['type'] == 'heading')
          $postbody .= '[color=red][u][b]' . $field['caption'] . '[/b][/u][/color]  ' . $_REQUEST[$field['name']] . '<br />';
        else
          $postbody .= '[color=green]' . $field['caption'] . '[/color]  ' . $_REQUEST[$field['name']] . '<br />';
      }
      $postbody .= '';

      $msgOptions = array(
        'id' =>  0 ,
        'subject' => '[Pending] Application of ' . $context['user']['name'],
        '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;
  }
}

// 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 a *.</div>';  }
  echo '<form action="' . $scripturl . '?page='  . $_GET['page'] . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
        <center><table width="50%">';
  $bg = 'windowbg2';
  foreach ($fielddef as $field) {
    if ($field['type'] == 'text') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><INPUT id="' . $field['name'] . '" name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" /></TD>
            </TR>';
    }
    elseif ($field['type'] == 'radio') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left">';
              $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 . ' ';
              }
              echo '</TD>
            </TR>';   
    }
    elseif ($field['type'] == 'checkbox') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              echo $field['caption'] . ':</TD>
              <TD align="left">';
                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'] . '
            </TR>';   
    }
    elseif ($field['type'] == 'select') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><SELECT id="' . $field['name'] . '" name="' . $field['name'] . '" style="WIDTH: 152px" value ="';
              echo '" />';
              $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></TD>
            </TR>';
    }
    elseif ($field['type'] == 'textarea') {
      echo '<TR class ="' . $bg . '">
            <TD width = "200px" align="right">';
            if ($field['required'] == 1) { echo '* '; }
            echo $field['caption'] . ':</TD>
            <TD align="left"><TEXTAREA id="' . $field['name'] . '" name="' . $field['name'] . '" rows="4" cols="40">';
            echo $fieldvalue[$field['name']];
            echo '</' . 'TEXTAREA></TD>
  </TR>';
    }
  elseif ($field['type'] == 'heading') {
      echo '<tr><TD colspan="2"><center><table cellSpacing="1" cellPadding="1" width="50%"><TR>
            <font size="8"><TD style="text-align: center; text-decoration: underline;"><font size="4">' .
            $field['caption'] .
            '</font></TD></TR></table></center></td></tr>';
    }
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
  }


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


The last bit of the code needs some work so recaptcha box appears either after the submit button or before but cant be outside of the </form> tag.

JPDeni

The reason it shows in the top is that you have it in the midst of a table, but you don't have it in a table row. The browser doesn't know where to put it, so it puts it on top.

I don't know where you moved the code to and got an error, but this should work:


echo '<TR class ="' . $bg . '"><td colspan="2" align="center">' . recaptcha_get_html($publickey) . '</td></tr>';
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
  echo '
     <br><TR class ="' . $bg . '">
      <TD colspan="2" align="center">
        <INPUT type="submit" value="Submit">
        <INPUT type="reset" value="Reset"></TD>
    </TR></TABLE></center></form>';


This even keeps the alternate colors for the rows, so your form has a unified appearance.

Inny

Really thanks, i dont know how to thank you but if you ever come to Cyprus (if you know where that is) i will buy coffee for you.  O0

JPDeni

:D Yes, I know where Cyprus is. :) I would love to come. I understand that it's beautiful.

You're very welcome. If you would like to pay me back, when you see someone who needs a cup of coffee but can't afford it, buy it for him. That would be thanks enough for me. :)

Inny

I decided to not go with ReCaptcha because you need to have the mod installed in order to work.

So i was working a bit with the code to add SMF visual verification system.

global $sourcedir, $user_info, $context ;

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


// CONFIGURATION SECTION

$intro_form = "<center><h4><font color=red>Even if this is nothing like the normal Applications that you make a post and have to be well written, we still demand that every field that requires a written answer to be well written. </font></h4> </center><br>";   // Can include html

$thanks_text = "<center><h3><font color=red>Thanks for applying. Your application has been submitted successfully. We'll review your application and get back to you.</h3></font></center>"; // what is displayed after the form is submitted

// 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' =>      "Email",
      'name' =>         "charemail",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
  ),
    array(
      'caption' =>      "Character Info",
      'name' =>         "heading1",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
array(
      'caption' =>      "Character Name",
      'name' =>         "charname",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Lever",
      'name' =>         "charlevel",
      'type' =>         "select",
      'options' =>      "70,71,72,73,74,75,76,77,78,79,80",
      'defaultvalue' => "80",
      'required' =>     1
    ),
    array(
      'caption' =>      "Race",
      'name' =>         "charrace",
      'type' =>         "select",
      'options' =>      "Orc,Undead,Troll,Tauren,Blood Elf",
      'defaultvalue' => "Orc",
      'required' =>     1
    ),
array(
      'caption' =>      "Class",
      'name' =>         "charclass",
      'type' =>         "select",
      'options' =>      "Druid,Hunter,Mage,Paladin,Priest,Rogue,Shaman,Warlock,Warrior,Death Knight",
      'defaultvalue' => "Druid",
      'required' =>     1
    ),
array(
      'caption' =>      "Days played",
      'name' =>         "charplayed",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Profession 1",
      'name' =>         "prof1",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
array(
      'caption' =>      "Profession 2",
      'name' =>         "prof2",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
   array(
      'caption' =>      "How are you speced?",
      'name' =>         "charspec",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Why you speced this way",
      'name' =>         "specinfo",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "What are you class important stats and why",
      'name' =>         "specstats",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Are you willing to respec for the Guild?",
      'name' =>         "guildspec",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "No",
      'required' =>     1
    ),
array(
      'caption' =>      "Do you have any other Characters?",
      'name' =>         "otherchars",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Armory Link",
      'name' =>         "armorylink",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Achievement Points",
      'name' =>         "achievementpoints",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "About You",
      'name' =>         "heading2",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Age",
      'name' =>         "charage",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
   array(
      'caption' =>      "Sex",
      'name' =>         "chargender",
      'type' =>         "select",
      'options' =>      "Male,Female,Yes Please,No Thanks",
      'defaultvalue' => "Yes Please",
      'required' =>     0
    ),
   array(
      'caption' =>      "Are You Emo?",
      'name' =>         "charemo",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "Yes",
      'required' =>     0
    ),
    array(
      'caption' =>      "Country",
      'name' =>         "charcountry",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Why we should pick you?",
      'name' =>         "guildpick",
      'type' =>         "textbox",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    );



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

// email address of recruitment staff member
$email_address='grkronos@gmail.com';

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

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


//END OF CONFIGURATION SECTION

$show_form= 'true';
if (isset($_REQUEST['submitted'])) {  // Handle the form

// Check whether the visual verification code was entered correctly.
if ((empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1) && (empty($_REQUEST['visual_verification_code']) || strtoupper($_REQUEST['visual_verification_code']) !== $_SESSION['visual_verification_code']))
{
$_SESSION['visual_errors'] = isset($_SESSION['visual_errors']) ? $_SESSION['visual_errors'] + 1 : 1;
if ($_SESSION['visual_errors'] > 3 && isset($_SESSION['visual_verification_code']))
unset($_SESSION['visual_verification_code']);

fatal_lang_error('visual_verification_failed', false);
}


// 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 = 'Enrollment Application';
  $body = 'Enrollment application has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . '
              ';
      foreach ($fielddef as $field) {
        $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 = 'Enrollment application has been made by ' . $context['user']['name'] .'<br /><br/>';
  foreach ($fielddef as $field) {
        if ($field['type'] == 'heading')
          $postbody .= '[color=red][u][b]' . $field['caption'] . '[/b][/u][/color]  ' . $_REQUEST[$field['name']] . '<br />';
        else
          $postbody .= '[color=green]' . $field['caption'] . '[/color]  ' . $_REQUEST[$field['name']] . '<br />';
      }
      $postbody .= '';

      $msgOptions = array(
        'id' =>  0 ,
        'subject' => '[Pending] Application of ' . $context['user']['name'],
        '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;
  }
}

// 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 a *.</div>';  }
  echo '<form action="' . $scripturl . '?page='  . $_GET['page'] . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
        <center><table width="50%">';
  $bg = 'windowbg2';
  foreach ($fielddef as $field) {
    if ($field['type'] == 'text') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><INPUT id="' . $field['name'] . '" name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" /></TD>
            </TR>';
    }
    elseif ($field['type'] == 'radio') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left">';
              $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 . ' ';
              }
              echo '</TD>
            </TR>';   
    }
    elseif ($field['type'] == 'checkbox') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              echo $field['caption'] . ':</TD>
              <TD align="left">';
                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'] . '
            </TR>';   
    }
    elseif ($field['type'] == 'select') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><SELECT id="' . $field['name'] . '" name="' . $field['name'] . '" style="WIDTH: 152px" value ="';
              echo '" />';
              $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></TD>
            </TR>';
    }
    elseif ($field['type'] == 'textarea') {
      echo '<TR class ="' . $bg . '">
            <TD width = "200px" align="right">';
            if ($field['required'] == 1) { echo '* '; }
            echo $field['caption'] . ':</TD>
            <TD align="left"><TEXTAREA id="' . $field['name'] . '" name="' . $field['name'] . '" rows="4" cols="40">';
            echo $fieldvalue[$field['name']];
            echo '</' . 'TEXTAREA></TD>
  </TR>';
    }
  elseif ($field['type'] == 'heading') {
      echo '<tr><TD colspan="2"><center><table cellSpacing="1" cellPadding="1" width="50%"><TR>
            <font size="8"><TD style="text-align: center; text-decoration: underline;"><font size="4">' .
            $field['caption'] .
            '</font></TD></TR></table></center></td></tr>';
    }
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
  }

// Generate a visual verification code to make sure the user is no bot.
$context['visual_verification'] = empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1;
if ($context['visual_verification'])
{
$context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
$context['verificiation_image_href'] = $scripturl . '?action=verificationcode;rand=' . md5(rand());

// Only generate a new code if one hasn't been set yet
if (!isset($_SESSION['visual_verification_code']))
{
// Skip I, J, L, O and Q.
$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P'), range('R', 'Z'));

// Generate a new code.
$_SESSION['visual_verification_code'] = '';
for ($i = 0; $i < 5; $i++)
$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}
}


if ($context['visual_verification'])
{
echo '
<tr>
<td width="40%" align="top" class="windowbg2">
<b>', $txt['visual_verification_label'], ':</b>
<div class="smalltext">', $txt['visual_verification_description'], '</div>
</td>
<td class="windowbg2">';

if ($context['use_graphic_library'])
echo '
<img src="', $context['verificiation_image_href'], '" alt="', $txt['visual_verification_description'], '" id="verificiation_image" /><br />';
else
echo '
<img src="', $context['verificiation_image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verificiation_image_1" />
<img src="', $context['verificiation_image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verificiation_image_2" />
<img src="', $context['verificiation_image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verificiation_image_3" />
<img src="', $context['verificiation_image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verificiation_image_4" />
<img src="', $context['verificiation_image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verificiation_image_5" />';
echo '
<input type="text" name="visual_verification_code" size="30" tabindex="', $context['tabindex']++, '" />

</td>
</tr>';
}


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


This is how far i reached and having 2 problems:
1) When you view the application next to the code it says "Not defined yet"
2) If you put the wrong code it breaks your page payout, only problem with my theme is that the footer becomes small

Inny

Or maybe instead of messing with captcha we can get a box that only accepts a specific number or a phrase for anti-spam.

This website is proudly hosted on Crocweb Cloud Website Hosting.