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: 459
  • Total: 459

Generic Application Form

Started by JPDeni, May 23, 2009, 11:04:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

raxavier69

#180
Seems to work, but when its posted is looks weird im looking at the code, isnt it suppose to be in a table? or certain things bold?

ZarPrime

raxavier69,

No tables, no bold.  As I said, this is the barebones code.  You can make any formatting changes to it that you desire.

As an example, when I first started working on editing the code for our support form, a resulting topic looked something like this ...
http://talesofthehavenexpanse.com/smf2test/index.php?topic=8.0

It looked quite a bit more unorganized than I really wanted it to be so I made changes.  After making some edits to the code, the resulting topics looked more like this ...
http://talesofthehavenexpanse.com/smf2test/index.php?topic=38.0

What I can do is post the code that I ended up with and if you want to make comparisons with the barebones code, you can see what I did to get the look I wanted.  Is that what you want me to do?

ZarPrime

raxavier69

i got fieldmaster to help thanks :) looks great. will post how it looks in a bit.

raxavier69

YAY!!
looks hot thanks for all the help

only thing is the check box i tried yes,no,maybe and yes;no;maybe and still didnt work. maybe its just me

JPDeni

The checkbox can not have multiple options. It's the sort of thing that is "check this if you want to get the newsletter." If you want several options, use a radio field.

raxavier69


Bloodlvst

Quote from: ZarPrime on June 08, 2010, 12:46:16 AM
raxavier69,

No tables, no bold.  As I said, this is the barebones code.  You can make any formatting changes to it that you desire.

As an example, when I first started working on editing the code for our support form, a resulting topic looked something like this ...
http://talesofthehavenexpanse.com/smf2test/index.php?topic=8.0

It looked quite a bit more unorganized than I really wanted it to be so I made changes.  After making some edits to the code, the resulting topics looked more like this ...
http://talesofthehavenexpanse.com/smf2test/index.php?topic=38.0

What I can do is post the code that I ended up with and if you want to make comparisons with the barebones code, you can see what I did to get the look I wanted.  Is that what you want me to do?

ZarPrime

I'd love that. It works great on my site except I want to make the forum output more human-readable :)

ZarPrime

If you want to setup this form for use with SMF 1.1.11, you should use the code in this topic ...
http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779

If you want to setup this form for use with SMF 2.0 RC3 and the latest TiinyPortal, you should use the code from this topic ... http://www.tinyportal.net/index.php?topic=29670.msg263560#msg263560

The code, with the markup as changed by me, for use as a Support Form on TinyPortal with SMF 2.0 RC3 and the latest TinyPortal, is shown below.  It was never used by us as there wasn't enough of a reason to use it.  However, it can be used as an example of how this code can be used to setup your own form.  Please be aware that there is a call to an image on my test site in the code.  I have changed the link to that image to a non-existent image.  You should refer to the differences between this code and the code in http://www.tinyportal.net/index.php?topic=29670.msg263560#msg263560 as this code below is specifically for SMF 2.0 RC3.


global $sourcedir, $context, $scripturl, $user_info;
///// ZP Edit - Globals below replaced by the above
//global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Generic Application Form
// Originally created by JPDeni, TinyPortal Coding Goddess, reference the topic below:
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
//
// Edited on 6 June, 2010 by ZarPrime to work with SMF 2.0 RC3 and TinyPortal 1.0 beta 5 (Polls not enabled in this version)

// Guests can't fill out the form
if ($context['user']['id'] == 0)
    echo 'You must be logged in before you can post a support topic.';
else {

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


// CONFIGURATION SECTION

$intro_form = "<div style=\"text-align: center;\"><img
style=\"width: 345px; height: 104px;\" alt=\"TinyPortal Support\"
title=\"TinyPortal Support Form\"
src=\"http://talesofthehavenexpanse.com/graphics/logo-supp.png\"
align=\"middle\"><br>
<br>
<div style=\"text-align: center;\"><big
style=\"font-weight: bold; text-decoration: underline;\">Posting
Guidelines<br>
</big>
<div style=\"text-align: left;\"><small><br>
<big>If you have never read the  <span
style=\"font-weight: bold; text-decoration: underline;\">new</span>
Posting Guidelines for the TinyPortal Support Board, or if you need
additional information about how to fill out the Support Form below,
please click the following link.<br>
<br>
</big></small>
<div style=\"text-align: center;\">Link goes here<br>
<br>
<div style=\"text-align: left;\"><span
style=\"font-weight: bold; text-decoration: underline;\">IMPORTANT
NOTE</span>:  Topics posted to the Support Board that
haven't used this Support Form will be placed at the bottom of the
priority list for Support.  What that means is that you should
post as much detail as possble in the Form so that we do not have to
ask multiple questions to get to a point where we can assist you.
 Fields marked with an asterisk (*) in the Form are required.<small></small></div>
</div>
</div>
</div>
</div>";
$thanks_text = "This is what will appear after the form is submitted. You can use html. Be careful with quotation marks.";

// 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' =>      "Briefly describe the issue in the Subject line below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Brief Subject",
'name' =>         "subject",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1   
),
array(
'caption' =>      "Please give a detailed description of the problem in the area below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Detailed Description",
'name' =>       "detail",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Click Yes below only if you have TinyPortal installed, else click No",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "TinyPortal Installed?",
'name' =>         "installed",
'type' =>         "radio",
'options' =>      "Yes,No",
'defaultvalue' => "",
'required' =>     1
), 
array(
'caption' =>      "What version of SMF is installed?",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Select SMF version",
'name' =>         "smf",
'type' =>         "select",
'options' =>      ",Older than 1.1,1.1,1.1.1,1.1.2,1.1.3,1.1.4,1.1.5,1.1.6,1.1.7,1.1.8,1.1.9,1.1.10,2.0 beta 3,2.0 beta 3.1,2.0 beta 4,2.0 RC1,2.0 RC1-1,2.0 RC1.2,2.0 RC2,2.0 RC3",
'defaultvalue' => "",
'required' =>     1
), 
array(
'caption' =>      "What version of TinyPortal is installed?",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Select TP version",
'name' =>         "tp",
'type' =>         "select",
'options' =>      ",Older than v0.98,v0.98,v1.0 beta 1,v1.0 beta 2,v1.0 beta 3,v1.0 beta 4,v1.0 beta 5,v1.0 beta 5-1,v1.0 beta 5.2,TP Not Installed",
'defaultvalue' => "",
'required' =>     1
), 
array(
'caption' =>      "Link to your site, e.g., http://www.tinyportal.net/index.php",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Your Site url",
'name' =>         "url",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1   
),
array(
'caption' =>      "List the Primary Theme and version that exhibits the problem",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Your Primary Theme",
'name' =>         "theme",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1   
),
array(
'caption' =>      "List other Themes and versions that exhibit the problem",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Other Themes in use",
'name' =>       "otherthemes",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "List the Primary Browser that exhibits the problem and the version below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Your Primary Browser",
'name' =>         "browser",
'type' =>         "text",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1   
),
array(
'caption' =>      "Other Browsers that exhibit the problem and their versions below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Other Browsers",
'name' =>       "otherbrowsers",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Cut and Paste your Mods list from the Package Manager into the area below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Your Mod List",
'name' =>       "modlist",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
array(
'caption' =>      "Paste related Error Messages below",
'name' =>         "heading",
'type' =>         "heading",
'options' =>      "",
'defaultvalue' => "",
'required' =>     0
),
array(
'caption' =>      "Error Messages",
'name' =>       "errorlist",
'type' =>         "textarea",
'options' =>      "",
'defaultvalue' => "",
'required' =>     1
),
);

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

// email address of recruitment staff member
$email_address='';

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

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


//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 = 'Support Topic';
$body = '';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$body .= $field['caption'] . '
';
else
$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 = 'Support Topic has been initiated by ' . $context['user']['name'] .'<br /><br />';
foreach ($fielddef as $field) {
// Now we aren't going to print the headings or the subject in the post
if ($field['type'] == 'heading' || $field['name'] == 'subject')
echo '
<br />';
else
$postbody .=  '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' =>  0 ,
// Use the one below if poster doesn't enter subject
//'subject' => '[Pending] Application of ' . addslashes($_REQUEST['realname']),
// Use the one below if poster does enter subject
'subject' => ($_REQUEST['subject']),
'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;
}
}
else {
foreach ($fielddef as $field) {
$fieldvalue[$field['name']] = $field['defaultvalue'];
}
}

// 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 an asterisk (*).</div>';  }

echo '
<form action="' . $scripturl . '?page='  . $_GET['page'] . '" method="post">
<INPUT name="submitted" type="hidden" value="TRUE" />
        <table style="margin-left:auto; margin-right:auto;">';

$bg = 'windowbg2';

foreach ($fielddef as $field) {
// Headings have their own type of display
if ($field['type'] == 'heading') {
echo '
<TR>
<TD colspan="2" style="text-align: center; text-decoration: underline;">' .
$field['caption'] . '
</TD>
</TR>';
}

else {

// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="left">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':
</TD>
<TD align="left">';

// Go through each field type
if ($field['type'] == 'text') {
echo '<INPUT name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" />';
}
elseif ($field['type'] == 'radio') {
$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 . ' ';
}
}
elseif ($field['type'] == 'checkbox') {
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'];   
}
elseif ($field['type'] == 'select') {
echo '<SELECT name="' . $field['name'] . '" />';
$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>';
}   
elseif ($field['type'] == 'textarea') {
echo '<TEXTAREA name="' . $field['name'] . '" rows="5" cols="80">';
echo $fieldvalue[$field['name']];
echo '</' . 'TEXTAREA>';
}

// Finish off the row
echo '
</TD>
</TR>';
}

// Set up the alternating colors for the next row
($bg == 'windowbg2') ? $bg = 'windowbg' : $bg = 'windowbg2';
}

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

RaXavier


ZarPrime

Quote from: RaXavier on November 13, 2010, 11:52:41 PM
nvm tp error

RaXavier,

I have no idea what you are talking about.  This topic was last posted to over 2 and a half months ago.  Was this post a mistake?

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.