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

Recent

Welcome to TinyPortal. Please login or sign up.

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

[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.

Kronos

#260
Thanks if you're willing to give it a go, it's quite some changes though.
Where I'd like a small text area for just a word or 3 I'll say TEXT, for a bigger textfield i'll say TEXTFIELD and for a drop down menu I'll say just that with the options I'd like.

QuoteName: TEXT
Age: TEXT
Any activities that will effect your availability (work/school/social): TEXTFIELD
A little about yourself: TEXTFIELD
Computer Specs (does your computer lag? do you have connection trouble?): TEXTFIELD

Information about your character
Class: DROPDOWN - Druid - Hunter - Mage - Paladin - Priest - Rogue - Shaman -Warlock - Warrior - Death Knight
Race: DROPDOWN - Orc - Undead - Troll - Tauren - Blood Elf
Alts (name/level/class/race/server): TEXTFIELD
Experience (Include which character this is on)
Pre-TBC: TEXTFIELD
TBC: TEXTFIELD
WotLK: TEXTFIELD
Spec: TEXTFIELD

Do you enjoy your main spec (you will be raiding in this spec): DROPDOWN - Yes - No

Willing to respec if the guild ask you to: DROPDOWN - Yes - No
Link to your armoury: TEXT
Do you have any resistance gear: TEXTFIELD
/Played: TEXT
Profession, and any rare recipes: TEXTFIELD
How much gold do you have: TEXT

Are you available to raid from 19.00 - 23.00 hours on the following days?
Monday: DROPDOWN - Yes - No
Tuesday: DROPDOWN - Yes - No
Wednesday: DROPDOWN - Yes - No
Thursday: DROPDOWN - Yes - No
Friday: DROPDOWN - Yes - No
Saturday: DROPDOWN - Yes - No

Do you have anything planned that will effect your availability (holidays/exams etc): TEXTFIELD
Heroic keys: TEXTFIELD
What can you offer Eternal Pain: TEXTFIELD
What are you looking for from Eternal Pain: TEXTFIELD
Do you know anyone in the guild who can vouch for you: TEXT
Have you applied anywhere else: TEXTFIELD
(or if possible, a dropdown with yes or no, if yes is selected a textfield, if no no textfield)

Previous guilds / reasons for leaving: TEXTFIELD
Can you confirm you have read, understand and agree to the guildrules? DROPDOWN - Yes - No
Further Comments: TEXTFIELD

As I've mentioned, its quite allot that needs to be added/changed so if you really cba I'll have to look somewhere else.

Oh and currently, I've set the guest permissions so that they cannot post. Though if you use this form whilst not logged in it does post as a guest, is there any way this can be fixed by for example showing "Please register" instead of the submit and reset buttons when you're not logged in or redirect?


Code:
global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

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

// email address of reqruitment staf 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=1;

//the id of the this article
$this_article_id = '6';

//article to be redirected when form is submitted
$thank_you_article_id = '5';


//END OF CONFIGURATION SECTION

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

// Check required fields
$enroll_errors = array(); //Initialize error array

// Check for a name
if (empty($_POST['real_name']) ){
$enroll_errors[] = 'You forgot to enter your name.';
}
// Check for an email
if (empty($_POST['email']) ){
$enroll_errors[] = 'You forgot to enter your email address.';
}
// Check for an AA name
if (empty($_POST['aa_name']) ){
$enroll_errors[] = 'You forgot to enter your In-Game Nickname.';
}       
// Check for an age
if (empty($_POST['age']) ){
$enroll_errors[] = 'You forgot to enter your age.';


if (empty($enroll_errors)) { //Everything seems to be OK
     
        $show_form='false';



// email an application

$subject = 'Enrollment Application';
$body = 'Enrollment application has been made by ' . $context['user']['name'] .
' from IP Address ' . $user_info['ip'] . '
Real Name:  ' . $_POST['real_name'] . '
Email address:  ' . $_POST['email'] . '
Current Game Name:  ' . $_POST['aa_name'] . '
Age:  ' . $_POST['age'] . '
Gender: ' . $_POST['gender'] . '
Location:  ' . $_POST['location'] . '
Current Honor:  ' . $_POST['honor'] . '
Previous clan(s):  ' . $_POST['prev_clans'] . '
Banned from any sever:  ' . $_POST['banned'] . '
Registered with AAOTracker? ' . $_POST['aaotracker'] . '
AAOTracker name:  ' . $_POST['aaotracker_name'] . '
Registred with X-fire?  ' . $_POST['xfire'] . '
X-Fire Account:  ' . $_POST['xfire_name'] . '
TeamSpeak installed?:  ' . $_POST['ts'] . '
Have microphone/headset:  ' . $_POST['mic'] . '
Would like to help pay for a server?: ' . $_POST['pay'] . '
Why do you want to join our clan?  ' . $_POST['why'] . '
Gaming habbits:   ' . $_POST['habbits'] . '
Other information:  ' . $_POST['other'];

$postbody = 'Enrollment application has been made by ' . $context['user']['name'] .'<br />
<table>
<tr><td>Real Name:<td></td><td>  ' . $_POST['real_name'] . '</td></tr>
<tr><td>Email address:<td></td><td>  ' . $_POST['email'] . '</td></tr>
<tr><td>Current Game Name:<td></td><td>  ' . $_POST['aa_name'] . '</td></tr>
<tr><td>Age:<td></td><td>  ' . $_POST['age'] . '</td></tr>
<tr><td>Gender: <td></td><td>' . $_POST['gender'] . '</td></tr>
<tr><td>Location:<td></td><td>  ' . $_POST['location'] . '</td></tr>
<tr><td>Current Honor: <td></td><td> ' . $_POST['honor'] . '</td></tr>
<tr><td>Previous clan(s): <td></td><td> ' . $_POST['prev_clans'] . '</td></tr>
<tr><td>Banned from any sever: <td></td><td> ' . $_POST['banned'] . '</td></tr>
<tr><td>Registered with AAOTracker? <td></td><td>' . $_POST['aaotracker'] . '</td></tr>
<tr><td>AAOTracker name:  <td></td><td>' . $_POST['aaotracker_name'] . '</td></tr>
<tr><td>Registred with X-fire? <td></td><td> ' . $_POST['xfire'] . '</td></tr>
<tr><td>X-Fire Account: <td></td><td> ' . $_POST['xfire_name'] . '</td></tr>
<tr><td>TeamSpeak installed?: <td></td><td> ' . $_POST['ts'] . '</td></tr>
<tr><td>Have microphone/headset: <td></td><td> ' . $_POST['mic'] . '</td></tr>
<tr><td>Would like to help pay for a server?:<td></td><td> ' . $_POST['pay'] . '</td></tr>
<tr><td>Why do you want to join our clan? <td></td><td> ' . $_POST['why'] . '</td></tr>
<tr><td>Gaming habbits: <td></td><td> ' . $_POST['habbits'] . '</td></tr>
<tr><td>Other information: <td></td><td> ' . $_POST['other']. '</td></tr>
</table>';



            if ($enable_email)
mail($email_address, $subject, $body,"From: " . $_POST['email']);



//create new forum post with application

$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,
);
   
if ($enable_post)
            createPost($msgOptions, $topicOptions, $posterOptions);

// Redirect to thank you page
header('Location: http://' . $_SERVER['HTTP_HOST'] .'/index.php?page=' . $thank_you_article_id);

} else {
// Redirect to error page
//header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php?page=' . $enroll_error_article_id );
echo '<h2 class="error">Error!</h2>';
echo '<p class="error">The following error(s) occured:<br />';

foreach ($enroll_errors as $msg) {
echo " - $msg<br />";
}
   echo "<p>Please, correct all errors and try again.</p>" ;



}
}
//else { // Display the form

echo '
<form action="index.php?page='  . $this_article_id  . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
<TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="95%" border="0">
<TR class ="windowbg">
<TD width = "200px">* Your Name:</TD>
<TD><INPUT id="real_name" name="real_name" type="text" value ="';
if (isset($_POST['real_name'])) echo $_POST['real_name'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Email address:</TD>
<TD><INPUT id="email" name="email" type="text" value ="';
if (isset($_POST['email'])) echo $_POST['email']; else echo $user_info['email']; 
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">* Current AA In-Game Nick:</TD>
<TD><INPUT id="aa_name" name="aa_name" type="text" value ="';
if (isset($_POST['aa_name'])) echo $_POST['aa_name'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Age:</TD>
<TD><INPUT id="age" name="age" type="text" value ="';
if (isset($_POST['age'])) echo $_POST['age'];   
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Gender:
</TD>
<TD><SELECT id = "gender" name = "gender" style="WIDTH: 152px" value ="';
if (isset($_POST['gender'])) echo $_POST['gender'];   
echo '" />
<OPTION value="No Answer" selected>--------------------------</OPTION>
<OPTION value="M">Male</OPTION>
<OPTION value="F">Female</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Location:</TD>
<TD><INPUT id="location" name="location" type="text" value ="';
if (isset($_POST['location'])) echo $_POST['location'];   
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Current Honor:</TD>
<TD><INPUT id="honor" name="honor" type="text" value ="';
if (isset($_POST['honor'])) echo $_POST['honor'];   
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Previous clan(s) and reason of leaving:</TD>
<TD><TEXTAREA id="prev_clans" name="prev_clans" rows="4" cols="40" value ="';
if (isset($_POST['prev_clans'])) echo $_POST['prev_clans'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Have you ever been permanently banned from any sever (if yes, give details):</TD>
<TD><TEXTAREA id ="banned" name ="banned" rows="4" cols="40"  value ="';
if (isset($_POST['banned'])) echo $_POST['banned'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Registered with AAOTracker?</TD>
<TD><SELECT id="aaotracker" name="aaotracker" style="WIDTH: 160px" value ="';
if (isset($_POST['aaotraker'])) echo $_POST['aaotraker'];   
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="YES">Yes</OPTION>
<OPTION value="NO">No</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">AAOTracker name:</TD>
<TD><INPUT id="aaotracker_name" name="aaotracker_name" type="text" value ="';
if (isset($_POST['aaotraker_name'])) echo $_POST['aaotraker_name']; 
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Registred with X-fire?</TD>
<TD><SELECT id="xfire" name="xfire" style="WIDTH: 160px" value ="';
if (isset($_POST['xfire'])) echo $_POST['xfire'];
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="YES">Yes</OPTION>
<OPTION value="NO">No</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">X-Fire Account:</TD>
<TD><INPUT id="xfire_name" name="xfire_name" type="text" value ="';
if (isset($_POST['xfire_name'])) echo $_POST['xfire_name'];   
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Do you have TeamSpeak installed?:</TD>
<TD><SELECT id="ts" name="ts" style="WIDTH: 160px" value ="';
if (isset($_POST['ts'])) echo $_POST['ts'];   
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="YES">Yes</OPTION>
<OPTION value="NO">No</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Do you have microphone/headset:</TD>
<TD><SELECT id="mic" name="mic" style="WIDTH: 160px" value ="';
if (isset($_POST['mic'])) echo $_POST['mic'];   
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="YES">Yes</OPTION>
<OPTION value="NO">No</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Would you help pay for a server?:</TD>
<TD><SELECT id="pay" name="pay" style="WIDTH: 160px" value ="';
if (isset($_POST['pay'])) echo $_POST['pay'];   
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="Monthly">Yes, monthly</OPTION>
<OPTION value="Occasionally">Yes, occasionally</OPTION>
<OPTION value="Not">No, not now</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Why do you want to join -WoW-?</TD>
<TD><TEXTAREA id="why" name ="why" rows="4" cols="40" value ="';
if (isset($_POST['why'])) echo $_POST['why'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Tell us about your gaming habbits:
</TD>
<TD><TEXTAREA id="habbits" name="habbits" rows="4" cols="40" value ="';
if (isset($_POST['habbits'])) echo $_POST['habbits'];
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Any other information you think can help us to make a decision:</TD>
<TD><TEXTAREA id="other" name = "other" rows="4" cols="40" value ="';
if (isset($_POST['other'])) echo $_POST['other'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD colspan="2" align="center">
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset"></TD>
</TR>
</TABLE>
</form>

';

JPDeni

I didn't realize you wanted their whole life story. :)

I'll see if I can get to it Monday. If someone else wants to tackle it before then, that's fine.

Kronos

Nah we just think many textfields are a good way to scare the noobs off :p

Really appreciate it, thanks in advance.

JPDeni

Sorry it took so long. I forgot about it. (Getting old is no fun.  :) )

I altered the code so that it's easier to edit. I combined it with another thing I wrote a while back so you can define your fields at the beginning and the code takes care of the rest.

I've tested this out and it works, both with posting to the forum and sending email:



global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

$intro_form = "This is where you give any instructions for filling out the form.";   // Can include html

$thanks_text = "Thanks ever so much for applying. We'll review your application and get back to you."; // 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' =>      "Any activities that will effect your availability (work/school/social)",
      'name' =>         "activities",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "A little about yourself",
      'name' =>         "bio",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Computer Specs (does your computer lag? do you have connection trouble?)",
      'name' =>         "computer",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Information about your character",
      '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' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Race",
      'name' =>         "race",
      'type' =>         "select",
      'options' =>      "Orc,Undead,Troll,Tauren,Blood Elf",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Alts (name/level/class/race/server)",
      'name' =>         "alts",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Experience (Include which character this is on)",
      'name' =>         "heading2",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "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' =>     1   
    ),
     array(
      'caption' =>      "Willing to respec if the guild ask you to",
      'name' =>         "respec",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "",
      'required' =>     1   
    ),
    array(
      'caption' =>      "Link to your armoury",
      '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' =>      "Are you available to raid from 19.00 - 23.00 hours on the following days?",
      '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' =>      "Do you have 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 Eternal Pain",
      'name' =>         "offer",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "What are you looking for from Eternal Pain",
      'name' =>         "looking",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
     array(
      'caption' =>      "Do you know anyone in the guild who can vouch for you",
      'name' =>         "vouch",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0   
    ),
    array(
      'caption' =>      "Have you applied anywhere else",
      'name' =>         "applied",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Previous guilds / reasons for leaving",
      'name' =>         "previous",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
     array(
      'caption' =>      "Can you confirm you have read, understand and agree to the guildrules?",
      'name' =>         "rules",
      'type' =>         "select",
      'options' =>      "Yes,No",
      'defaultvalue' => "",
      'required' =>     1   
    ),
    array(
      'caption' =>      "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='grkronos@gmail.com';

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

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


//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="100%">';
  $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 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>';
}



I did some guessing on which fields you would like to have required. You can easily change them.

I also eliminated the need for a separate "Thank you" page. You can put whatever you want to display on the page after the form is submitted in the $thanks_text variable, which is defined right near the top.

I also added a "field type" called header, which just sets off different sections. You can put any html in there that you want, to make the text centered or bigger or bolder or whatever. Just be sure you don't set the header to being required.  :)

Kronos

Thank you so much, really nice.

CliMa

Hi guys i created a form and got it all sorted with sending the email but when i click submit and wait to go onto the thank you page it gives me an error saying cannot find page. for the thank you page its number 71, Heres the coding i am using, any help would be great.

global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

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

// email address of reqruitment staf member
$email_address='----@hotmail.co.uk';

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

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

//the id of the this article
$this_article_id = '72';

//article to be redirected when form is submitted
$thank_you_article_id = '71';


//END OF CONFIGURATION SECTION

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

// Check required fields
$enroll_errors = array(); //Initialize error array

// Check for a name
if (empty($_POST['real_name']) ){
$enroll_errors[] = 'You forgot to enter your name.';
}
// Check for an email
if (empty($_POST['email']) ){
$enroll_errors[] = 'You forgot to enter your email address.';
}
// Check for an PSN name
if (empty($_POST['psn_name']) ){
$enroll_errors[] = 'You forgot to enter your In-Game Nickname.';
}       
// Check for an age
if (empty($_POST['age']) ){
$enroll_errors[] = 'You forgot to enter your age.';

// Check for Available Times
if (empty($_POST['available']) ){
$enroll_errors[] = 'You forgot to enter your available times.';

// Check for Preferred Position
if (empty($_POST['position']) ){
$enroll_errors[] = 'You forgot to enter your preferred position.';



if (empty($enroll_errors)) { //Everything seems to be OK
     
        $show_form='false';



// email an application

$subject = 'Application Form';
$body = 'Application has been made by ' . $context['user']['name'] .
' from IP Address ' . $user_info['ip'] . '
Real Name:  ' . $_POST['real_name'] . '
Email address:  ' . $_POST['email'] . '
Current Game Name:  ' . $_POST['psn_name'] . '
Age:  ' . $_POST['age'] . '
Gender: ' . $_POST['gender'] . '
Location:  ' . $_POST['location'] . '
Available Times:  ' . $_POST['available'] . '
Preferred Position:  ' . $_POST['position'] . '
Would like to help pay for the site?: ' . $_POST['pay'] . '
Why do you want to join our clan?  ' . $_POST['why'];

$postbody = 'Application has been made by ' . $context['user']['name'] .'<br />
<table>
<tr><td>Real Name:<td></td><td>  ' . $_POST['real_name'] . '</td></tr>
<tr><td>Email address:<td></td><td>  ' . $_POST['email'] . '</td></tr>
<tr><td>Current Game Name:<td></td><td>  ' . $_POST['psn_name'] . '</td></tr>
<tr><td>Age:<td></td><td>  ' . $_POST['age'] . '</td></tr>
<tr><td>Gender: <td></td><td>' . $_POST['gender'] . '</td></tr>
<tr><td>Location:<td></td><td>  ' . $_POST['location'] . '</td></tr>
<tr><td>Available Times:  <td></td><td> ' . $_POST['available'] . '</td></tr>
<tr><td>Preferred Position: <td></td><td> ' . $_POST['position'] . '</td></tr>
<tr><td>Would like to help pay for the site?:<td></td><td> ' . $_POST['pay'] . '</td></tr>
<tr><td>Why do you want to join our clan? <td></td><td> ' . $_POST['why'] . '</td></tr>
</table>';



            if ($enable_email)
mail($email_address, $subject, $body,"From: " . $_POST['email']);



//create new forum post with application

$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,
);
   
if ($enable_post)
            createPost($msgOptions, $topicOptions, $posterOptions);

// Redirect to thank you page
header('Location: http://' . $_SERVER['HTTP_HOST'] .'smf/index.php?page=71' . $thank_you_article_id);

} else {
// Redirect to error page
//header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php?page=' . $enroll_error_article_id );
echo '<h2 class="error">Error!</h2>';
echo '<p class="error">The following error(s) occured:<br />';

foreach ($enroll_errors as $msg) {
echo " - $msg<br />";
}
   echo "<p>Please, correct all errors and try again.</p>" ;



}
}
//else { // Display the form

echo '
<form action="index.php?page='  . $this_article_id  . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
<TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="95%" border="0">
<TR class ="windowbg">
<TD width = "200px">* Your Name:</TD>
<TD><INPUT id="real_name" name="real_name" type="text" value ="';
if (isset($_POST['real_name'])) echo $_POST['real_name'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Email address:</TD>
<TD><INPUT id="email" name="email" type="text" value ="';
if (isset($_POST['email'])) echo $_POST['email']; else echo $user_info['email']; 
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">* Current PSN Nick:</TD>
<TD><INPUT id="psn_name" name="psn_name" type="text" value ="';
if (isset($_POST['psn_name'])) echo $_POST['psn_name'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Age:</TD>
<TD><INPUT id="age" name="age" type="text" value ="';
if (isset($_POST['age'])) echo $_POST['age'];   
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Gender:
</TD>
<TD><SELECT id = "gender" name = "gender" style="WIDTH: 152px" value ="';
if (isset($_POST['gender'])) echo $_POST['gender'];   
echo '" />
<OPTION value="No Answer" selected>--------------------------</OPTION>
<OPTION value="M">Male</OPTION>
<OPTION value="F">Female</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Location:</TD>
<TD><INPUT id="location" name="location" type="text" value ="';
if (isset($_POST['location'])) echo $_POST['location'];   
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Available Times(for play/practice):</TD>
<TD><TEXTAREA id="available" name="available" rows="4" cols="40" value ="';
if (isset($_POST['available'])) echo $_POST['available'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">* Preferred Position:</TD>
<TD><TEXTAREA id ="position" name ="position" rows="4" cols="40"  value ="';
if (isset($_POST['position'])) echo $_POST['position'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Would you help pay for the site?:</TD>
<TD><SELECT id="pay" name="pay" style="WIDTH: 160px" value ="';
if (isset($_POST['pay'])) echo $_POST['pay'];   
echo '" />
<OPTION value="No answer" selected>--------------------------</OPTION>
<OPTION value="Monthly">Yes, monthly</OPTION>
<OPTION value="Occasionally">Yes, occasionally</OPTION>
<OPTION value="Not">No, not now</OPTION>
</SELECT></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Why do you want to join World Elite League?</TD>
<TD><TEXTAREA id="why" name ="why" rows="4" cols="40" value ="';
if (isset($_POST['why'])) echo $_POST['why'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD colspan="2" align="center">
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset"></TD>
</TR>
</TABLE>
</form>

';

JPDeni

It looks like you changed the code. The original line is


header('Location: http://' . $_SERVER['HTTP_HOST'] .'/index.php?page=' . $thank_you_article_id);


You have


header('Location: http://' . $_SERVER['HTTP_HOST'] .'smf/index.php?page=71' . $thank_you_article_id);


IOW, it's looking for page=7171.

Change it back to the original and you should be fine.

CliMa

Thanks for your quick reply.

I changed that but still getting "HTTP 404 Not Found" when i hit submit.

JPDeni

Are you sure there is a page 71?

If so, try something else...

In the first line of the code, add $scripturl to the list of variables. It should look like


global $sourcedir, $user_info, $context, $scripturl ;


Then change


header('Location: http://' . $_SERVER['HTTP_HOST'] .'/index.php?page=' . $thank_you_article_id);


to


header('Location: ' . $scripturl . '?page=' . $thank_you_article_id);

CliMa

#269
Thanks mate worked a treat, also is there a way i can move the form so its in the center,

any ideas ?

This website is proudly hosted on Crocweb Cloud Website Hosting.