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: 361
  • Total: 362
  • 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.

JPDeni

I fixed the error. Those nasty parentheses.

QuoteAlso which part should i remove so guests are able to fill a form.

:)

Delete


if ($ID_MEMBER == 0)
    echo 'You must be logged in before you can apply.';
else {


and the very last


}


Inny

Parse error: syntax error, unexpected '/' on line 243  ???

JPDeni


Inny

Thanks Working now  :up:

Razzik

When someone includes a link (armory link etc.) in the application form, it creates post on forum but upon opening the post it gives this error
Database Error: MySQL server has gone away
File: /home/a7981124/public_html/Sources/Subs.php
Line: 703


I tried it without links and everything was fine.

Can anyone help me?

Thanks in advance

JPDeni

What code are you using? There are 39 pages in this topic with lots and lots of variations on the code. Also, can you look into your database via something like phpMyAdmin and see what the post looks like?

Razzik

Ok I fixed it, thanks anyway.
Somehow when I removed the text-decoration: underline; it wouldnt work.

Azphat12

#387
Hello, its me again!   ;D

Was wondering if you could help me clean this application up.  It is working, but I have tried a few times to alter the looks of it to no avail. 

Here are some screenshots...

Recruitment Form
http://screenshots.darkaftermath.com/recruitmentform.jpg

Recruitment Post
http://screenshots.darkaftermath.com/recruitmentformpost.jpg

Here is the code I am using...

global $sourcedir, $ID_MEMBER, $context ;

if ($ID_MEMBER == 0)
    echo 'You must be logged in before you can apply.';
else {

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


// CONFIGURATION SECTION

$intro_form = "<center><h4><font color=white>Even if this is nothing like the normal Applications that you are used too, we still expect that every field that requires a written answer to be well written.<p>Please take the time to fill out each field, as this is your first impression to the guild.</p></font></h4> </center><br>";   // Can include html

$thanks_text = "<center><h3><font color=white>Thanks for applying. Your application has been submitted successfully.<br>We'll review your application and get back to you.<p>Typical response time is 24-48 hours.</p>If you are not contacted by then, please message an officer in-game to discuss your application status.<p>Thank You,<br>Dark Aftermath Recruitment</p></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' =>      "Personal Info",
'name' =>         "heading1",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Name",
'name' =>         "realname",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1  
),
array(
'caption' =>      "Age",
'name' =>         "age",
'type' =>         "select",
'options' =>      "18,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40+",
'defaultvalue' => "18",
'required' =>     1
), 
array(
'caption' =>      "Email",
'name' =>         "charemail",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Member Referral",
'name' =>         "referral",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
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' =>      "Level",
'name' =>         "charlevel",
'type' =>         "select",
'options' =>      "80,79,78,77,76,75,74,73,72,71",
'defaultvalue' => "80",
'required' =>     1
),
array(
'caption' =>      "Race",
'name' =>         "charrace",
'type' =>         "select",
'options' =>      "Draenei,Dwarf,Gnome,Human,Night Elf",
'defaultvalue' => "Draenei",
'required' =>     1
),
array(
'caption' =>      "Class",
'name' =>         "charclass",
'type' =>         "select",
'options' =>      "Death Knight,Druid,Hunter,Mage,Paladin,Priest,Rogue,Shaman,Warlock,Warrior",
'defaultvalue' => "Death Knight",
'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' =>      "Primary Spec?",
'name' =>         "primaryspec",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Secondary Spec?",
'name' =>         "secondaryspec",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Armory Link?",
'name' =>         "armory",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Why you speced this way",
'name' =>         "specinfo",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Willing to respec?",
'name' =>         "specstats",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Additional Questions",
'name' =>         "heading1",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "What can you offer<br>Dark Aftermath?",
'name' =>         "offer",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "What are you looking for in<br>Dark Aftermath?",
'name' =>         "looking",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Additional Comments?",
'name' =>         "decision",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Competency Test",
'name' =>         "test",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
);



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

// email address of recruitment staff member
$email_address='recruitment@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
if (!isset($_REQUEST['mathtest']) or ($_REQUEST['mathtest'] <> 12))
$errors[] = 'You didn' . "'" . 't get the math problem correct';

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 = 'Recruitment Application';
$body = 'Recruitment 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 = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '[color=white][u][b]' . $field['caption'] . '[/b][/u][/color]<br />';
elseif ($field['type'] == 'textarea') {
$text = $_REQUEST[$field['name']];
$length = 150; // maximum length of a line
$output = '';
while (strlen($text) > $length) {
$textlen = strlen($text);
$part = substr($text,0,$length);
$partlen = $length;
while (substr($part,-1) <> ' ') {
$part = substr($part,0,-1);
--$partlen;
}
$output .= $part . '<br />';
$text = substr($text,$partlen,($textlen-$partlen));
}
$output .= $text;
$postbody .= '[color=#5BAFDF]' . $field['caption'] . '[/color]<br />' . $output . '<br />';
}
else
$postbody .= '[color=#5BAFDF]' . $field['caption'] . '[/color]  ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' =>  0 ,
'subject' => '[Pending] Application of ' . $_REQUEST['charname'] . ' ' . $_REQUEST['charclass'],
'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'] . '</TD>
</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 name="' . $field['name'] . '" style="WIDTH: 152px" />';
$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>
<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 '
<TR class ="' . $bg . '"><td>What is 5 + 7? (enter a number)</td>
<td><input type="text" name="mathtest" value=""></td></tr>';
if ($bg == 'windowbg2') { $bg = 'windowbg'; }
else { $bg = 'windowbg2'; }
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>';
}
}


Everytime I try I either get a parse error, or it doesnt look proper.  I just want the application to look nice. 

JPDeni

#388
Overall -- if you want to have different structures for different fields of the same type, you'll need to use different code. For example, if you want a textarea to have the label to the side on one field and on top on another field, you can't use this code. Or, if you want one text field to be longer than the others, you'll need to use other code.

If you want to extend the length of the text fields, you can do that. Find the section that prints out text fields and put in a size tag.


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']] . '" size="40"/></TD>
</TR>';
}


See where I put size="40"? Adjust that number until it's what you want.

I'm not sure what you mean by
QuoteCan "Willing to respec" box be changed to a short box
If you want a one-line text field instead of a textarea, just set it in the field definition.

Change

'caption' =>      "Willing to respec?",
'name' =>         "specstats",
'type' =>         "textarea",


to


'caption' =>      "Willing to respec?",
'name' =>         "specstats",
'type' =>         "text",


As for moving the field, just move the field definition. The fields are displayed in the same order that you define them.

You ask
QuoteCan this box be removed?
Of course. Just delete it from the field definition.

If you want the labels for textareas to be above the field instead of to the side, change

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>';
}


to


elseif ($field['type'] == 'textarea') {
echo '<TR class ="' . $bg . '">
<TD> </td><td>';
if ($field['required'] == 1) { echo '* '; }
echo $field['caption'] . ':</TD></tr>
<tr><td> </td><TD align="left"><TEXTAREA id="' . $field['name'] . '" name="' . $field['name'] . '" rows="4" cols="40">';
echo $fieldvalue[$field['name']];
echo '</' . 'TEXTAREA></TD>
</TR>';
}


As for the display, it seems that everything is okay, except that you say
QuoteI was wondering if we could have it say Passed?

You can have it say Rumplestiltskin if you want. ;)

I'm assuming that you only want it to say PASSED if they get the "mathest" right.

Before

$msgOptions = array(


Add


if (isset($_REQUEST['mathest']) && $_REQUEST['mathest'] == 12)
    $postbody .= 'PASSED';

Azphat12

This is fantastic.  I will get on this and let you know what I end up with.

Thank you!!    ;D

This website is proudly hosted on Crocweb Cloud Website Hosting.