Application Form

Simple Machines Forum integration forum

Application Form

Postby lacitpo » Mon Jun 11, 2007 8:34 pm

I've enjoyed using SMF and Tinyportal for my guild's web site. However i've seen a few guild sites that have an actual form that applicants fill out.

If someone could code an SMF mod to do this it would be amazing.
lacitpo
WR.net Apprentice
WR.net Apprentice
 
Posts: 7
Joined: Mon Jan 15, 2007 3:23 pm

Re: Application Form

Postby lacitpo » Mon Jun 11, 2007 8:57 pm

I just started looking up a few things and here are the two most
usefull things I've found.

The function in smf that creates new posts

http://support.simplemachines.org/funct ... nction=377

And a guy who kinda layed out how to do this.

http://www.simplemachines.org/community ... ic=73630.0

I still know too little about this to code it myself, but I bet one of you guru's out there could do this with their eyes closed. anyone willing to contribute?
lacitpo
WR.net Apprentice
WR.net Apprentice
 
Posts: 7
Joined: Mon Jan 15, 2007 3:23 pm

Re: Application Form

Postby Adariel » Mon Sep 07, 2009 6:30 pm

I have a working Application on my Raven Flight site. I got it from a guy on the SMF boards and I don't remember his name, but he gave it to me with the understanding that he wasn't willing or able to provide support/help for it. I tweaked it for my own use and I offer it here with the same caveat ...

Mine does 4 things:
1. Checks to make sure the person has an account and is logged in. If they aren't, it offers them the login fields and the link to register.
2. Once logged in, shows them the form to fill out.
3. Takes the form and posts it on a particular board using a given account (I used my admin account).
4. Sends the user to a basic thank you page.

First you have to install the Custom Actions mod. Then you'll need to create 3 new Custom Actions. I named mine "apply", "apply2", and "thanks". Copy and paste the appropriate code as follows, adjusting as needed to match your own settings - specifically look for "yourdomain", "our guild", and "/path/to/":

apply - a PHP action:
Code: Select all
global $context, $user_info, $ID_MEMBER;

if ( $context['user']['is_guest'] )
{
   //make user login or register
   echo <<<EOG
<div class="tborder" style="margin-bottom: 2px; ">
   <div style="padding: 3px 6px 3px 6px;" class="titlebg"><a href="http://www.yourdomain.com/index.php?page=apply"><b>Membership Application</b></a></div>
   <table width="100%" cellpadding="0" cellspacing="0">
      <tr>
         <td valign="top"  class="windowbg2" style="padding: 4px;">
            <div style="_height: 1%; overflow: auto;"><div>
            <div class="body" align="justify">
            <center><b>Thank you for your interest in membership in our guild.</b></center><br /><br />
            In order to apply, please follow these steps:<br />
            1. <a href="index.php?action=register">Register a user account</a><br />
            2. <a target=new href="index.php?page=charter">Read the Guild Charter</a><br />
            3. <a href="index.php?action=apply">Complete the application</a><br /><br />

            If you have already registered, please login below.<br /><br />

EOG;
   $_SESSION['login_url'] = 'http://www.yourdomain.com' . $_SERVER['PHP_SELF'] . '?action=apply';
   ssi_login();

   echo <<<EOG
            <br /><br /><br /></div>
         </td>
      </tr>
   </table>
</div>

EOG;

   exit;
}

$username=$user_info['username'];
$useremail=$user_info['email'];
$userid=$ID_MEMBER;

$appform = <<<EOF

<script language="javascript">
function setRace(g){
   var Race = document.form1.Race;
   Race.options.length = 0;
   if (g == "WoW"){
      Race.options[Race.options.length] = new Option('Human');
      Race.options[Race.options.length] = new Option('Gnome');
      Race.options[Race.options.length] = new Option('Night Elf');
      Race.options[Race.options.length] = new Option('Dwarf');
      Race.options[Race.options.length] = new Option('Draenei');
   }
}
function setClass(r){
   var Class = document.form1.Class;
   Class.options.length = 0;
   // WoW Races
   if (r == "Human"){
      Class.options[Class.options.length] = new Option('Mage');
      Class.options[Class.options.length] = new Option('Paladin');
      Class.options[Class.options.length] = new Option('Priest');
      Class.options[Class.options.length] = new Option('Rogue');
      Class.options[Class.options.length] = new Option('Warrior');
      Class.options[Class.options.length] = new Option('Warlock');
      Class.options[Class.options.length] = new Option('Deathknight');
   }
   if (r == "Gnome"){
      Class.options[Class.options.length] = new Option('Mage');
      Class.options[Class.options.length] = new Option('Rogue');
      Class.options[Class.options.length] = new Option('Warlock');
      Class.options[Class.options.length] = new Option('Warrior');
      Class.options[Class.options.length] = new Option('Deathknight');
   }
   if (r == "Night Elf"){
      Class.options[Class.options.length] = new Option('Druid');
      Class.options[Class.options.length] = new Option('Hunter');
      Class.options[Class.options.length] = new Option('Priest');
      Class.options[Class.options.length] = new Option('Rogue');
      Class.options[Class.options.length] = new Option('Warrior');
      Class.options[Class.options.length] = new Option('Deathknight');
   }
   if (r == "Dwarf"){
      Class.options[Class.options.length] = new Option('Hunter');
      Class.options[Class.options.length] = new Option('Paladin');
      Class.options[Class.options.length] = new Option('Priest');
      Class.options[Class.options.length] = new Option('Rogue');
      Class.options[Class.options.length] = new Option('Warrior');
      Class.options[Class.options.length] = new Option('Deathknight');
   }
   if (r == "Draenei"){
      Class.options[Class.options.length] = new Option('Hunter');
      Class.options[Class.options.length] = new Option('Mage');
      Class.options[Class.options.length] = new Option('Paladin');
      Class.options[Class.options.length] = new Option('Priest');
      Class.options[Class.options.length] = new Option('Shaman');
      Class.options[Class.options.length] = new Option('Warrior');
      Class.options[Class.options.length] = new Option('Deathknight');
   }
}
</script>

<div class="tborder" style="margin-bottom: 2px; ">
   <div style="padding: 3px 6px 3px 6px;" class="titlebg"><a href="http://www.yourdomain.com/index.php?page=about"><b>Membership Application</b></a></div>
   <table width="100%" cellpadding="0" cellspacing="0"><tr><td valign="top"  class="windowbg2" style="padding: 4px;"><div style="_height: 1%; overflow: auto;"></div><div class="body" align="center">
      <br /><br />Please complete this form to apply for membership in our guild. Required fields are marked with a <font color="red">*</font>.<br /><br /><br />
      <FORM action="http://www.yourdomain.com/index.php?action=apply2" method="post" name="form1">
      <table align="center" cellpadding="15" cellspacing="15"><tr><td valign="top">
         <table align="right">
            <tr><td colspan="2" align="center"><b>Character Information</b></td></tr>
            <tr><td align="right"><font color="red">*</font>Name:</td><td><INPUT type="text" name="CharacterName" size="12" maxlength="12"></td></tr>
            <tr><td align="right"><font color="red">*</font>Level:</td><td><INPUT type="text" name="level" size="3" maxlength=""></td></tr>
            <tr><td align="right"><font color="red">*</font>Race:</td><td>
               <SELECT name="Race" size="1" onchange="setClass(document.form1.Race.options [document.form1.Race.selectedIndex].value);">
                  <OPTION value="Human">Human</OPTION>
                  <OPTION value="Gnome">Gnome</OPTION>
                  <OPTION value="Night Elf">Night Elf</OPTION>
                  <OPTION value=Dwarf">Dwarf</OPTION>
                  <OPTION value="Draenei">Draenei</OPTION></select></td></tr>
            <tr><td align="right"><font color="red">*</font>Class:</td><td>
               <SELECT name="Class" size="1">
                  <OPTION>Druid</OPTION>
                  <OPTION>Hunter</OPTION>
                  <OPTION>Mage</OPTION>
                  <OPTION>Paladin</OPTION>
                  <OPTION>Rogue</OPTION>
                  <OPTION>Shaman</OPTION>
                  <OPTION>Warlock</OPTION>
                  <OPTION>Warrior</OPTION></SELECT></td></tr>
            <tr><td align="right"><font color="red">*</font>Time Zone:</td><td><select name="TZ" size="1"><OPTION>Eastern</OPTION><OPTION>Central</OPTION><OPTION>Mountain</OPTION><OPTION>Pacific</OPTION></select></td></tr>
            <tr><td valign="top"><font color="red">*</font>Usual playtimes:</td><td><INPUT name="play" type="text" size="20" maxlength=""></td></tr>
         </table></td><td valign="top">
            <table align="left">
            <tr><td colspan="2" align="center"><b>General Information</b></td></tr>
            <tr><td valign="top">What game(s) have you played?</td><td valign="top"><INPUT name="prevgames" type="text" size="20" maxlength=""></td></tr>
            <tr><td valign="top">Were you referred by an active member? If so by whom?</td><td valign="top"><INPUT name="ref" type="text" size="20" maxlength=""></td></tr>
            <tr><td valign="top">What style(s) of play do you enjoy most? (PvE, PvP, Raids)</td><td valign="top"><INPUT name="enjoy" type="text" size="20" maxlength=""></td></tr>
            <tr><td valign="top"><font color="red">*</font>Why do you wish to join?</td><td valign="top"><TEXTAREA name="whyjoin" rows="2" cols="16"></TEXTAREA></td></tr>
         </table></td></tr>
         <tr><td align="center">Do you consider yourself a hardcore, every day player?<br /><INPUT type="radio" name="hardcore" value="Yes"> Yes &nbsp;&nbsp;<INPUT type="radio" name="hardcore" value="No"> No</td>
            <td align="center"><font color="red">*</font>Have you read and agree to the guild <a target=new href="http://www.yourdomain.com/index.php?page=charter">Charter</a>?</LABEL><br /><INPUT type="radio" name="rules" value="Yes"> Yes &nbsp;&nbsp;<INPUT type="radio" name="rules" value="No"> No</td></tr>
         <tr><td colspan="2" align="center">
            <INPUT type="hidden" name="Username" value="$username"><INPUT type="hidden" name="Useremail" value="$useremail">
            <INPUT type="hidden" name="UserID" value="$userid">
            <INPUT type="submit" value="Send"> <INPUT type="reset">
         </td></tr>
      </table></form>
   </div></td></tr></table>
</div>

EOF;

echo $appform;


apply2 - a PHP action:
Code: Select all
global $db_prefix;

// Load SSI.php in so we have all the SMF functions available.

if (! isset($sourcedir))
{
   $sourcedir = '/home/path/to/Sources';
}
//echo '<!-- ' . $sourcedir . ' -->';
require_once($sourcedir . '/Subs-Post.php'); //require_once($sourcedir . '/Security.php');

//Get the posted Data
$CharacterName= $_POST['CharacterName'];
$Race= $_POST['Race'];
$Class = $_POST['Class'];
$level= $_POST['level'];
$TZ= $_POST['TZ'];
$prev= $_POST['prevgames'];
$play= $_POST['play'];
$ref= $_POST['ref'];
$enjoy= $_POST['enjoy'];
$hardcore= $_POST['hardcore'];
$whyjoin= $_POST['whyjoin'];
$rules= $_POST['rules'];

$forumuser= $_POST['Username'];
$email= $_POST['Useremail'];
$id= $_POST['UserID'];
$profile_url= '[iurl=http://www.yourdomain.com/index.php?action=profile;u='.$id.']'.$forumuser.'[/iurl]';

$errors=0;
/*$error .="The following errors occured while processing your form input.<ul>";
if($CharacterName=="" || $Race=="" || $Class=="" || $level=="" || $TZ=="" || $playtime=="" || $whyjoin=="" || $rules=="" ){
   $errors=1;
   $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}*/

if($errors==1)
{
   echo $error;
}
else
{
   $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));

   //
   //-----------------------------

   $subject = "Guild App - $forumuser";

$message = "
Forum Username: $profile_url
Email Address: $email

$CharacterName - Lv $level   $Race $Class


Previous Games Played:
    $prev

Time Zone: $TZ
Play Times: $play

References:
    $ref

Play style(s) enjoyed:
    $enjoy

Hardcore Player: $hardcore

Why applicant wants to join:
    $whyjoin

Read Guild Rules: $rules
";


   //--------------------------------------


   header("Refresh: 5;url=http://www.yourdomain.com/index.php?action=thanks");

   echo '
<div class="tborder" style="margin-bottom: 2px;">
   <div style="padding: 3px 6px 3px 6px;" class="titlebg"><b>Your Application Is Being Processed</b></a></div>
   <table width="100%" cellpadding="0" cellspacing="0"><tr><td valign="top" class="windowbg2" style="padding: 4px;"><div style="_height: 1%; overflow: auto;"></div>
      <div class="body" align="center">
         <br /><br /><br /><br /><br />
         Thank you '.$forumuser.'.<br /><br />Please wait a moment while your application is submitted.
         <br /><br /><br /><br /><br />
      </div>
   </td></tr></table>
</div>';

   // The ID of the board to put the post in.
   $board = 1;

   // Poster ID, name, and email address. (the Admin account is default)
   $posterID = 1;
   $posterName = 'Admin';

   // We've got the message, now post it and get its ID.
   db_query("
      INSERT INTO {$db_prefix}messages
         (ID_BOARD, ID_MEMBER, subject, posterName, posterEmail, posterTime,
         posterIP, smileysEnabled, body, icon)
      VALUES ($board, $posterID, '$subject', '$posterName', '$posterEmail', " . time() . ",
         '127.0.0.1', 0, '$message', 'xx')", __FILE__, __LINE__);
   $ID_MSG = db_insert_id();

   // Insert the new topic.
   db_query("
      INSERT INTO {$db_prefix}topics
         (ID_BOARD, ID_MEMBER_STARTED, ID_MEMBER_UPDATED, ID_FIRST_MSG, ID_LAST_MSG, numViews, ID_POLL)
      VALUES ($board, $posterID, $posterID, $ID_MSG, $ID_MSG, 0, 0)", __FILE__, __LINE__);
   $topic = db_insert_id();

   // Fix the message with the topic.
   db_query("
      UPDATE {$db_prefix}messages
      SET ID_TOPIC = $topic
      WHERE ID_MSG = $ID_MSG
      LIMIT 1", __FILE__, __LINE__);

   // Increase the number of posts and topics on the board.
   db_query("
      UPDATE {$db_prefix}boards
      SET numPosts = numPosts + 1, numTopics = numTopics + 1
      WHERE ID_BOARD = $board
      LIMIT 1", __FILE__, __LINE__);

   // There's been a new topic AND a new post today.
   trackStats(array('topics' => '+', 'posts' => '+'));

   // Update all the stats so everyone knows about this new topic and message.
   updateStats('topic');
   updateStats('message');
   updateLastMessages($board);

   // The trackStats() function does caching, so let's actually make it change the database.
   trackStats();
}


thanks - an HTML action:
Code: Select all
<div class="tborder" style="margin-bottom: 2px; ">
   <div style="padding: 3px 6px 3px 6px;" class="titlebg"><b>Your Application Has Been Submitted</b></a></div>
   <table width="100%" cellpadding="0" cellspacing="0"><tr><td valign="top" class="windowbg2" style="padding: 4px;"><div style="_height: 1%; overflow: auto;"></div><div class="body" align="center">
      <b>Thank you for submitting your application.</b><br /><br /><br />
      The information you provided has been posted to the leadership to be discussed.<br />
      You will be contacted with our decision within 7 days.<br /><br />
      Click <a href="/index.php">here</a> or use the menu above to visit other sections of our site<br /><br /><br /><br />
   </div></td></tr></table>
</div>
User avatar
Adariel
WR.net Apprentice
WR.net Apprentice
 
Posts: 36
Joined: Tue Jul 25, 2006 9:14 am


Return to SMF

Who is online

Users browsing this forum: No registered users and 0 guests

cron