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,973
  • Latest: NonStop
Stats
  • Total Posts: 196,230
  • Total Topics: 21,353
  • Online today: 446
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 276
  • Total: 276

Warcraft Recruitment Form

Started by Azphat12, April 14, 2009, 02:00:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Azphat12

I got this code from this site awhile back, and for the life of me cannot find it again.  It was working on my former tinyportal, but after getting updated to version 1 it is giving me errors. 

Here are the errors...

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/darkaft1/public_html/forums/Sources/Load.php(1735) : eval()'d code(1080) : eval()'d code on line 3

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/darkaft1/public_html/forums/Sources/Load.php(1735) : eval()'d code(1080) : eval()'d code on line 3

Parse error: syntax error, unexpected '/' in /home/darkaft1/public_html/forums/Sources/Load.php(1735) : eval()'d code(1080) : eval()'d code on line 3

Unfortunately I am good at editing, but lousy and the actual coding stuff. 

Here is the code for the PHP article

global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

$intro_form = \"<br><center>Please take your time to fill out the form.  This is your first impression, so make it a good one.<br>Please use your character name.</center><br>\";   // Can include html

$thanks_text = \"<br><center>Thanks ever so much for applying. We\'ll review your application and get back to you.</center><br>\"; // 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\' =>      \"Name\",
      \'name\' =>         \"name\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
    array(
      \'caption\' =>      \"Age\",
      \'name\' =>         \"age\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1
    ),
    array(
      \'caption\' =>      \"Availability\",
      \'name\' =>         \"activities\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"A little about yourself\",
      \'name\' =>         \"bio\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"Computer Specs (does your computer lag? do you have connection trouble?)\",
      \'name\' =>         \"computer\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"<br><center>Information about your character</center><br>\",
      \'name\' =>         \"heading1\",
      \'type\' =>         \"heading\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"Class\",
      \'name\' =>         \"class\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Druid,Hunter,Mage,Paladin,Priest,Rogue,Shaman,Warlock,Warrior,Death Knight\",
      \'defaultvalue\' => \"Druid\",
      \'required\' =>     1
    ),
    array(
      \'caption\' =>      \"Race\",
      \'name\' =>         \"race\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Draenei,Dwarf,Gnome,Human,Night Elf\",
      \'defaultvalue\' => \"Draenei\",
      \'required\' =>     1
    ),
    array(
      \'caption\' =>      \"Alts (name/level/class/race/server)\",
      \'name\' =>         \"alts\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"<br><center>Experience</center><br>\",
      \'name\' =>         \"heading2\",
      \'type\' =>         \"heading\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"<br>Pre-TBC\",
      \'name\' =>         \"pretbc\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  


    ),
    array(
      \'caption\' =>      \"TBC\",


      \'name\' =>         \"tbc\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"WotLK\",
      \'name\' =>         \"WotLK\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Spec\",
      \'name\' =>         \"Spec\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
     array(
      \'caption\' =>      \"Do you enjoy your main spec (you will be raiding in this spec)\",
      \'name\' =>         \"enjoy\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
     array(
      \'caption\' =>      \"Willing to respec if the guild ask you to\",
      \'name\' =>         \"respec\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Link to your armory\",
      \'name\' =>         \"armoury\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Do you have any resistance gear\",
      \'name\' =>         \"resistance\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"/Played\",
      \'name\' =>         \"played\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Profession, and any rare recipes\",
      \'name\' =>         \"profession\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"How much gold do you have\",
      \'name\' =>         \"gold\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"<br><center>What is your raid availability</center><br>\",
      \'name\' =>         \"heading2\",
      \'type\' =>         \"heading\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
     array(
      \'caption\' =>      \"Monday\",
      \'name\' =>         \"monday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
     array(
      \'caption\' =>      \"Tuesday\",
      \'name\' =>         \"tuesday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
     array(
      \'caption\' =>      \"Wednesday\",
      \'name\' =>         \"wednesday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
     array(
      \'caption\' =>      \"Thursday\",
      \'name\' =>         \"thursday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
     array(
      \'caption\' =>      \"Friday\",
      \'name\' =>         \"friday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
     array(
      \'caption\' =>      \"Saturday\",
      \'name\' =>         \"saturday\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     1  
    ),
    array(
      \'caption\' =>      \"Anything planned that will effect your availability (holidays/exams etc)\",
      \'name\' =>         \"plans\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",


      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"Heroic keys\",
      \'name\' =>         \"keys\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"What can you offer Dark Aftermath\",
      \'name\' =>         \"offer\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"What are you looking for from Dark Aftermath\",
      \'name\' =>         \"looking\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
     array(
      \'caption\' =>      \"Member Referral\",
      \'name\' =>         \"vouch\",
      \'type\' =>         \"text\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Have you applied anywhere else\",
      \'name\' =>         \"applied\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
    array(
      \'caption\' =>      \"Previous guild(s) reasons for leaving\",
      \'name\' =>         \"previous\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
     array(
      \'caption\' =>      \"Can you confirm you have read, understand and agree to the guild rules?\",
      \'name\' =>         \"rules\",
      \'type\' =>         \"select\",
      \'options\' =>      \"Yes,No\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0  
    ),
    array(
      \'caption\' =>      \"Contact Info and Further Comments\",
      \'name\' =>         \"comment\",
      \'type\' =>         \"textarea\",
      \'options\' =>      \"\",
      \'defaultvalue\' => \"\",
      \'required\' =>     0
    ),
);


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

//email address of recruitment staff member
$email_address=\'gyza@darkaftermath.org\';

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

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


//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 = \'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 />
                   <table>\';
      foreach ($fielddef as $field) {
        $postbody .= \'<tr><td>\' . $field[\'caption\'] . \'<td></td><td>  \' . $_REQUEST[$field[\'name\']] . \'</td></tr>\';
      }
      $postbody .= \'</table>\';

      $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=\"550px\">\';
  $bg = \'windowbg2\';
  foreach ($fielddef as $field) {
    if ($field[\'type\'] == \'text\') {
      echo \'<TR class =\"\' . $bg . \'\">
              <TD width = \"200px\" align=\"left\">\';
              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=\"left\">\';
              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=\"left\">\';
              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=\"left\">\';
              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=\"left\">\';
            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 class =\"\' . $bg . \'\">
            <TD colspan=\"2\">\' .
            $field[\'caption\'] .
            \'</TD></TR>\';
    }
    if ($bg == \'windowbg2\') { $bg = \'windowbg\'; }
    else { $bg = \'windowbg2\'; }
  }
  echo \'
    <TR class =\"\' . $bg . \'\">
      <TD colspan=\"2\" align=\"center\">
        <INPUT type=\"submit\" value=\"Submit\">


        <INPUT type=\"reset\" value=\"Reset\"></TD>
    </TR></TABLE></center></form>\';
}


Hoping somebody can understand what is going on.  I dont have a up and running site right now that this works on but you can get the error message by going to

http://www.darkaftermathguild.com/forums/index.php?page=4

JPDeni

Find the original code and paste it in again.

Karma

Quote from: JPDeni on April 14, 2009, 02:03:11 AMFind the original code and paste it in again.
Or you could just use Custom Form :o) It works great for us (http://www.cocacolaguild.com/) if you want to check it out.

Azphat12

I cannot find the "original" author's code.  This code was working on Tinyportal 0.98.  Since upgrading to the Tinyportal 1 Beta 3 I get the errors.

I have been looking for the original code post to see if there are any replies that would help me, but I cannot find it in any search I do.  Searched on this site, and on google with no luck.  Was hoping someone would know about some changes to the Login.php file that might of been made, and see where in my code the conflict is.

I already fixed one of the errors.

$email_address=\'gyza@darkaftermath.org\';

needed to be changed to

$email_address='gyza@darkaftermath.org';

Karma

I would probably remove all the escapes (\) from the quotes, that is going to cause you trouble.. The only time you should escape a quote, is if it's inside another quote (eg: $foo = 'bar\'s'; instead of $foo = \'bar\'s\';)

It's more than likely the original poster of the code, or the forums it was posted to was overcompensating when sanitising the quoted code for the query which saved the original post.

That might not be all that's wrong, but it's the most obvious thing that needs fixing =)

Azphat12

Well I dont really understand the 'why', but I do understand how to remove those.  I am not overly code literate, but I can edit it up like a mad man!   ;D

I will try that and see what happens.

Karma

Without understanding the language and the rules, I wish you well my friend ;o)..

Some things you might want to look out for: $x = \'a\' . \'b\'; should come out as $x = 'a' . 'b'; in most cases. (There could be exceptions where the author did intend $x = 'a\' . \'b'; though this is unlikely.) when two variables are separated by a '.' it's effectively saying "put these together" so 'a' . 'b' would be 'ab'.

Good luck :o)

Azphat12

I know it isnt necessarily the perfect way, but I typically will change only 1 or 2 items.  Refresh everything and see if it is working.  If it isnt I change them back, and move on.  Good ole process of elimination...

Karma

Quote from: Azphat12 on April 14, 2009, 03:20:10 AM
I know it isnt necessarily the perfect way, but I typically will change only 1 or 2 items.  Refresh everything and see if it is working.  If it isnt I change them back, and move on.  Good ole process of elimination...
You will need to change them all, I believe.

I would expect that
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/darkaft1/public_html/forums/Sources/Load.php(1735) : eval()'d code(1080) : eval()'d code on line 3
Would read:
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/darkaft1/public_html/forums/Sources/Load.php(1735) : eval()'d code(1080) : eval()'d code on line 4
If you were to change the first require line to "require_once($sourcedir . '/Subs.php');" and reload it.

You will need to change them all, until you no longer see any "Unexpected character in input: '\'".

Then either your form will be working, or we'll have something more meaningful to work with.

JPDeni

The reason for the problem is a glitch in the editor.

You can edit all the quoted lines to remove the \ characters or you can find the original code (probably the "Join us! form" topic in the Block code snippets board) and repaste it in.

This website is proudly hosted on Crocweb Cloud Website Hosting.