This is designed for those who wish to make an application form for their site.
| type: | php article |
| author: | JPDeni |
| name: | Application Form |
| version: | .1 |
| date: | 16 Apr 2009 |
| discussion topic: | http://www.tinyportal.net/index.php/topic,9840.0.html (sort of) |
| description: |
- Creates a form to be filled out by prospective members
- Form fields are defined within the text, to include text, textarea, select, radio and checkbox fields
- Results can be emailed to an admin, posted to a specified board or both
|
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Generic Application Form
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
// Guests can't fill out the form
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 = "Put whatever introduction you want to appear at the top of the form here. You can add html. Be careful with quotation marks.";
$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' => "Heading",
'name' => "heading",
'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' => "13,14,15,16,17,18,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' => "Sex",
'name' => "sex",
'type' => "radio",
'options' => "M,F",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Do you like me?",
'name' => "like",
'type' => "checkbox",
'options' => "Yes",
'defaultvalue' => "Yes",
'required' => 0
),
array(
'caption' => "Comments",
'name' => "comments",
'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=2;
// Poll options
$add_poll = 1; // 0 = No poll; 1 = add poll
$poll_question = "Accept this member?"; // This is the question for the poll
$expireTime = 0; // Change this to the number of days you want the poll to run
$hideResults = 0; // 0 = Results are always visible; 1 = Can see results only after voting; 2 = Can see results only after poll expires
$changeVote = 0; // 0 = Voters can not change their votes; 1 = Voters can change their votes
$poll_choices = array('Yes','No'); // The options listed for the poll
//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 = 'Application';
$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
if ($add_poll === 1) {
$posterName = $context['user']['name'];
if ($expireTime > 0)
$expireTime = time() + $expireTime * 3600 * 24;
db_query("
INSERT INTO {$db_prefix}polls
(question, hideResults, maxVotes, expireTime, ID_MEMBER, posterName, changeVote)
VALUES ('$question', '$hideResults', '1', '$expireTime', '$ID_MEMBER', '$posterName', '$changeVote')", __FILE__, __LINE__);
$ID_POLL = db_insert_id();
// Create each answer choice.
$i = 0;
$setString = '';
foreach ($poll_choices as $option)
{
$setString .= "
('$ID_POLL', '$i', SUBSTRING('$option', 1, 255)),";
$i++;
}
db_query("
INSERT INTO {$db_prefix}poll_choices
(ID_POLL, ID_CHOICE, label)
VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
}
else
$ID_POLL = null;
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['realname']),
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => $ID_POLL,
'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 a *.</div>'; }
echo '
<form action="' . $_SERVER['REQUEST_URI'] . '" 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="right">';
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="4" cols="40">';
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>';
}
}
23 Sep 2009 -- Minor alteration to make the script work in blocks as well as articles.
30 Nov 2009 -- Added function to add a poll
Thanks for sharing JP
This is the same thing that I posted in the "Join us form" topic. I just created my own topic for it so people could figure out what code to use if they want to use mine.
Jp Deni,
Thanks for sorting this out for me. I'm going to try it now.
Should we put this in the Block Code Snippets Board as a [Block]?
ZarPrime
Thanks, JPDeni! It is pretty easy to follow and commented well. Great job! I am going to try this.
Already tried it and it works great.
Now I've just gotta find a use for it. :coolsmiley:
http://www.ourfamilyforum.org/FamilyForum/index.php?page=197
I'm surprised you didn't put "yes" or "no" as options for "sex"! LMAO
QuoteI'm surprised you didn't put "yes" or "no" as options for "sex"! LMAO
:2funny:
QuoteShould we put this in the Block Code Snippets Board as a [Block]?
That's where I thought I had it. :uglystupid2:
Thanks for posting the code here JPDeni. :)
I had one question for you though, I noticed when submitting the application the thread title reads.."[Pending] Application of " but doesn't include the name of the user submitting the form. Is it supposed to work this way?
It would be confusing having the same title over and over in a board. ;)
I had taken that code from where someone had altered it for themselves. I guess I didn't look at it really closely. The person had set the post title to correspond with his own field names. You can alter the line to match your own field names. Just do a search for "[Pending]" and then put the field name in the brackets. Like:
'subject' => '[Pending] Application of ' . $_REQUEST['realname'],
I just changed it to match one of the sample fields that I have in my code. Put your own field name instead of realname.
That fixed it, thanks for the help! :)
I've noticed that when going to the application form page it generates a few errors and this is before submitting the form.
Here are the errors and respective lines:
8: Undefined variable: scripturl
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 256
<form action="' . $scripturl . '?page=' . $_GET['page'] . '" method="post">
8: Undefined variable: fieldvalue
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 286
echo '<INPUT name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" />';
8: Undefined variable: fieldvalue
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 313
echo $fieldvalue[$field['name']];
These errors only come up when viewing the application form.
After submitting I get different errors in the log.
8: Undefined index: heading
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 216
$postbody .= '[color=red][u][b]' . $field['caption'] . '[/b][/u][/color] ' . $_REQUEST[$field['name']] . '<br />';
8: Undefined index: charclass
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 223
'subject' => '[Pending] Application of ' . $_REQUEST['realname'] . ' ' . $_REQUEST['charclass'],
8: Undefined variable: user_info
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 240
'email' => $user_info['email'],
I apologize for the long post but I'm trying to be as detailed as possible.
Also, BTW the form seems to work properly when viewing and submitting.
Any help would be appreciated, thanks in advance! :)
Maybe I'll just shut this down until I can get it to go. I thought it was ready. It appears I was wrong.
It does work properly though, just creates the errors.
Sorry to be the bearer of bad news JPDeni. :(
It's all right. I just didn't realize that when I tried to clean up someone's usage of my code that they had altered it so much. I appreciate your telling me, even if it is embarrassing.
I've fixed all of the issues you mention (some were fixed yesterday). If you find anything else, let me know. :)
I tried your new code and copied everything below "END OF CONFIG...." and got an error. I then copied the new code entirely and unfortunately received the same error.
Parse error: syntax error, unexpected '.' in /home/xxx/public_html/forum/Sources/Load.php(1753) : eval()'d code(586) : eval()'d code on line 124
Not really sure what's up, looks like it's going to be one of those nights. ;)
Oh, dea. I should have pasted it into my test page. I found two errors. Corrected code is in place.
Could I get any assistant in using this same code to work with the CustomAction mod?
I don't know how the Custom Action mod works, so I wouldn't be able to help you.
We are almost there JPDeni! :)
I'm still getting this error when posting...
8: Undefined variable: user_info
File: /home/xxx/public_html/forum/Themes/default/languages/TPShout.english.php (eval?)
Line: 243
I've also got a question, any idea how to bold each subject heading in the post?
Thanks for all the help, great block/article. ;)
I've added the variable to the "global" line.
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 .= '[b]'. $field['caption'] . '[/b]<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
Thank you so much for this. It is exactly what I have been looking for. I'm only having one issue.
If someone uses this form an adds an ' in any of the textboxes the forums show it as a hacking attempt and throws up an error page. I know there is an easy way to fix this but I'll be darned if I can think of it this early in the morning. :P
I'm running TP v1.0 beta 4 with SMF 1.1.9 I've attached my code for the article if you would like to take a peek.
orderoftwilight.com
Thanks for your time!
Change
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . $_REQUEST['realname'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
to
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . $_REQUEST['realname'],
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
Let me know how it works. If that's the fix, I'll alter the original code.
That did it! Thanks a bunch. I knew it was something simple. :P
I just forgot about it. I'm glad you mentioned it. Off to fix the original code.
Thank you!
I also added "addslashes" to the 'subject' line. Some of my forum members have very strange names. Seems to be working great.
Thank you again for looking into this.
Hi,
Love the form!! Would it be possible to have this open to guests to complete as I wish to invite them to provide information/feedback to the site (registration is disabled).
Regards,
Wilsy.
I'm not going to put this in the main code because I think it's a bad idea, but I'll give you the code here.
Change
if ($ID_MEMBER == 0)
to
// If you want guests to be able to fill this out, set it to 1.
// Note that you will not be able to have an email sent with the information.
$allow_guests = 0;
if ($ID_MEMBER == 0 && $allow_guests == 0)
and change
if ($enable_email)
to
if ($enable_email && $ID_MEMBER > 0)
The reason that you can't have an email sent if it's a guest that's doing it is that the email function uses the user's email address as the "From" on the email. With a guest, there is no "From."
The reason this is a really bad idea is that there are such things as spammers and 'bots who just lu-u-u-u-uve to find open forms for them to fill out. I did not put any security measures in this because they're not necessary when you have registered users using the form. If you want to add security, you'll need to do that yourself.
Quote from: JPDeni on June 16, 2009, 01:49:55 PM
The reason this is a really bad idea is that there are such things as spammers and 'bots who just lu-u-u-u-uve to find open forms for them to fill out. I did not put any security measures in this because they're not necessary when you have registered users using the form. If you want to add security, you'll need to do that yourself.
ahahaha.... yeah, I have an open form on my site, it gets quite a bit of spam. I want to add reCaptcha to it. It's a form that come packaged with the hosting plan of my site.
Thanks JP and Zetan, really appreciated. I might add another level of membership based off guests and reopen registration which should do the trick ;)
Are there any known issues with this on TPv1.0 beta 4? I've been trying to get this to work. I pasted this code into a .php and called for it in an article, but it always says 'you need to be logged in' regardless of whether or not you are logged in. I have also attempted to put this straight into a PHP article, but then it won't even save. It returns a 500 Internal Server Error.
Any ideas?
QuoteI pasted this code into a .php and called for it in an article
QuoteI have also attempted to put this straight into a PHP article
I don't know what either one of those things means. You need to create a php article from within TP, paste the code into the article and save it.
No one has brought up any issues with beta 4. Are you able to save any other php file?
What I meant was, I saved the code in a file called "application.php" and changed my article type to External Article. This method always says "You must be logged in before you can apply".
For the second, I did exactly what you said - Create a php article, paste, save. And it gives me an internal server error.
I am able to save just plain text in a php article, but it seems to give me an error whenever I add code.
QuoteI saved the code in a file called "application.php" and changed my article type to External Article.
It wasn't designed for that. It was designed to go into a php article.
QuoteI am able to save just plain text in a php article, but it seems to give me an error whenever I add code.
Then your problem isn't with my code. The best thing to do is to start a topic for support with your php article problem.
Thanks the code JPDeni, works fine except for one little thing mainly due to the fact that i don't use English language in it.
French language uses 'special' characaters that cause some issues, here's an exemple
"c'est l'heure" becomes "c\'est l\'heure"
any clue ? :)
thanks
I'm sorry. I don't.
Hi,
First I would like to say thanks for the code, it works really well, however ive found one issue with this, however it should be fixable.
Here is an example of an array i used.
array(
'caption' => "<FONT COLOR=red>Age</font>",
'name' => "age",
'type' => "select",
'options' => "13,14,15,16,17,18,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
If you note the color html or any html for that matter, ie; bold text
This all looks great on the form and looks great in the forum post however, if I go to modify the post exg; change topic from pending to accepted the body of the post becomes full of html that is out putted into html in the form of a php ' echo ' instead of keeping its coding.
I have attempted a solution with this line of your code.
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 .= $field['caption'] . '<br />';
else
$postbody = '[html]' . $field['caption'] . ': ' . $_REQUEST[$field['name']] . '[/html]<br />';
This would solve the issue upon editing however after the alteration of adding [html] brackets after the application is posted it will only display the comments section.
I am using a stock copy of your code unaltered except for the alterations posted above obtained from the first page on this thread.
Any help or solutions you could provide would be great.
Thanks
QuoteThis all looks great on the form and looks great in the forum post however, if I go to modify the post exg; change topic from pending to accepted the body of the post becomes full of html that is out putted into html in the form of a php ' echo ' instead of keeping its coding./quote]
That's because the code wasn't written to do that. If you want to change the outputted formatting, you should change it in the output part of the code, not the field definitions.
What exactly wasn't the code written to do?
You have in the php comments that html/color is allowed, but when posted it appears fine but to modify the post will display the pure html with no remorse or line breaks upon saving.
$postbody = '[html]' . $field['caption'] . ': ' . $_REQUEST[$field['name']] . '[/html]<br />';
Should resolve the issue however, the code will only echo the last array when modified.
The code was not written to have html code included in the names of the fields.
My comments say the following:
$intro_form = "Put whatever introduction you want to appear at the top of the form here. You can add html. Be careful with quotation marks.";
$thanks_text = "This is what will appear after the form is submitted. You can use html. Be careful with quotation marks.";
Those comments apply to those variables only. The note about the caption says
Can include symbols and spaces.
Nothing about html. It's too complicated for a generic form, as you seem to have found out.
If you can find a way to resolve it, that's great, but it's not the way the code was intended.
JPDeni,
I have a question. The "heading" field type appears to be centered as it should be. However, for the other field types, it looks like there is a TD in the code to align the other fields to the left, but none of them seem to be aligned left except the one with the checkbox.
The code for align left that I'm talking about starts with ...
<TD align="left">';
// Go through each field type
What can I do to make sure that the other fields (not the heading fields) align left in the form? See Pic below.
ZarPrime
They look like they're aligned to the left to me. The left column (the labels) is aligned to the right and the right column (the fields) is aligned to the left. That way they meet more or less in the middle. Not really the middle because of the varying sizes of the labels and the fields and there's really nothing I can do about that.
But maybe I'm not understanding what you mean.
ETA: Are you talking about the labels lining up to the left? If that's what you want, you'll need to change
// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
if ($field['required'] == 1) { echo '* '; }
echo $field['caption'] . ':
</TD>
<TD align="left">';
// Go through each field type
to
// 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
The reason that the label connected with the checkbox appears to be aligned to the left is that it's the longest label, so it fills the entire width of the column.
Ah, OK I see what you mean. The fields themselves are aligned left in the right TD. What I was trying to do was align the labels so that that would be aligned left in the left TD like this ...
*Name:
*Age:
*Sex:
Do you like me?:
rather than like this ...
* Name:
* Age:
* Sex:
Do you like me?:
However, that may not look right either if I have a long label because it would probably push the right TD to far to the right. OK, I'll have to think about that some more.
Thanx,
ZP
I edited my post to show you how to align them to the left, if you want to give it a try and see how it looks.
OK, that is definitely what I was looking for, but I'm undecided if that's the look I want when the label is long. That answers the question though. :up:
TYVM,
ZP
Edit: Well, it doesn't look so good with the comments field (the longest one) is set for cols="40" but when I changed it to 80 it looks pretty good. I may do one other thing. I might change the font for the labels to a fixed width font like courier or something. That would let me add content to fill in the labels so that they end closer to the fields. It looks pretty good this way.
YWVM,
JPD
;)
Check my edit above. I changed the cols on the comments field to 80 and it looks pretty good.
That's great! There's a lot of things that people can do to make it look like they want it to, which is why I kept the formatting at a minimal level in the basic code.
It's gratifying to see someone work with the code and bend it to their will. :D
Question about the heading
Is it possible to get the heading like this in the code:
Heading < bolded
question 1
question 2
question 3
Heading 2 < bolded
question 1
question 2
question 3
Since my php skills is poor i have no idea how to do this in the code.
Look for
// 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>';
}
In the line
<TD colspan="2" style="text-align: center; text-decoration: underline;">
put whatever you want as inline css. The default has it centered and underlined, but you can put whatever you want in there. No php involved. :-)
i tried that i want this to be shown as a post on the forums when an application been made not in the default "question" thing.
it seems not work for me. i get some stuff working but all Text is not being posted on the forums. Anyone know why?
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info;
// Guests can't fill out the form
if ($ID_MEMBER == 0)
echo 'Fel! Du måste vara inloggad innan du kan göra en ansökan till Valhalla Legion.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "Även om detta applikations system inte är som alla andras gillens så vet vi på Valhalla Legion att DU tar din tid och skriver ner nogranna svar på de frågor som kommer upp eftersom detta kommer vara vårat första intryck på dig som person.";
$thanks_text = "Tack för din ansökan till Valhalla Legion. Din ansökan har nu skickats till alla officerare i guildet via E-Mail samt så har denna ansökan kommit upp på forumet och kommer granskas innom 24 timmar. Har du inte fått ett svar innom 48 timmar så får du kontakta någon av officerarna i guildet som är Knax eller Nahiag.";
// 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' => "Personlig Information",
'name' => "Personlig Informaition",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Namn",
'name' => "Namn",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Ã…lder",
'name' => "Ã…lder",
'type' => "select",
'options' => "13,14,15,16,17,18,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' => 0
),
array(
'caption' => "Kille/Tjej",
'name' => "Gen",
'type' => "radio",
'options' => "Kille,Tjej",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Berätta Lite om dig själv",
'name' => "Lite om mig själv",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Karraktärs Information",
'name' => "Karraktärs Information",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Karraktärs namn",
'name' => "charname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Level",
'name' => "charlvl",
'type' => "select",
'options' => "80,79,78,77,76",
'defaultvalue' => "80",
'required' => 0
),
array(
'caption' => "Ras",
'name' => "charrace",
'type' => "select",
'options' => "Dranei,Dwarf,Human,Night Elf,Gnome",
'defaultvalue' => "Dranei",
'required' => 0
),
array(
'caption' => "Klass",
'name' => "charclass",
'type' => "select",
'options' => "Death Knight,Druid,Hunter,Mage,Paladin,Priest,Rogue,Shama,Warlock,Warrior",
'defaultvalue' => "Death Knight",
'required' => 0
),
array(
'caption' => "Primär Spec",
'name' => "charspec",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Secondär Spec",
'name' => "Secondär Spec",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Respecar du din klass om vi ber om det?",
'name' => "Respecar du din klass om vi ber om det?",
'type' => "radio",
'options' => "Ja,Nej",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "/Played",
'name' => "/Played",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Armory Länk",
'name' => "Armory Länk",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Är det du själv som har levlat upp din character?",
'name' => "Levlat upp gubben själv",
'type' => "radio",
'options' => "Ja,Nej",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Vilka dagar/tider kan du raida på (Va specifik)",
'name' => "Vilka dagar/tider kan du raida på (Va specifik)",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Raid Frågor",
'name' => "Raid Frågor",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Raidade du Classic? Hur långt kom du?",
'name' => "Raidade du Classic? Hur långt kom du?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Raidade du TBC? Hur långt kom du?",
'name' => "Raidade du TBC? Hur långt kom du?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Vad är din nuvarande RAID progress i WOTLK? (Va specifik)",
'name' => "Vad är din nuvarande RAID progress i WOTLK? (Va specifik)",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Vad gör dig till en bra medspelare i raids?",
'name' => "Vad gör dig till en bra medspelare i raids?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Är du en klicker?",
'name' => "Är du en klicker?",
'type' => "radio",
'options' => "Ja,Nej,Lite av båda",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Har du en FUNGERANDE mic?",
'name' => "Har du en FUNGERANDE mic?",
'type' => "radio",
'options' => "Ja,Nej",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Guild Relaterade Frågor",
'name' => "Guild Relaterade Frågor",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Är du med i ett guild? isf vilket?",
'name' => "Är du med i ett guild? isf vilket?",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Om JA på frågan över varför vill du lämna guildet?",
'name' => "Om JA på frågan över varför vill du lämna guildet?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Om NEJ på frågan varför har du lämnat/blivit kickad från guildet?",
'name' => "Om NEJ på frågan varför har du lämnat/blivit kickad från guildet?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Vad kan DU erbjuda Valhalla Legion som spelare?",
'name' => "Vad kan DU erbjuda Valhalla Legion som spelare?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Vad kan Valhalla Legion erbjuda DIG som spelare?",
'name' => "Vad kan Valhalla Legion erbjuda DIG som spelare?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Finns det någon som kan Rekomendera dig i Valhalla Legion?",
'name' => "Finns det någon som kan Rekomendera dig i Valhalla Legion?",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Ãâ€"vrigt",
'name' => "Ãâ€"vrigt",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Kan du något roligt skämt?",
'name' => "Kan du något roligt skämt?",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
);
//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=13.0;
//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 = 'Application';
$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 = 'Ansökningen har gjorts av ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br /><br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[OAVSLUTAT] ' . $_REQUEST['charlvl'] . ' ' . $_REQUEST['charspec'] . ' ' . $_REQUEST['charclass'] . ' ' . $_REQUEST['charname'] ,
'body' => addslashes($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;">Du har inte fyllt i alla fält med en stjärna *.</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;"><b>' .
$field['caption'] . '</b>
</TD>
</TR>';
}
else {
// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
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="4" cols="40">';
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>';
}
}
Quoteall Text is not being posted on the forums.
Can you be more specific? What is and what is not being posted? An example would help to narrow things down.
it is only the class, name, played, that is posted i think there is a leak somewer i get this error:
8: Undefined index: Kan du något roligt skämt?
File: /hsphere/local/home/kenta81/valhallalegion.se/Themes/default/TPortal.template.php (main sub template - eval?)
Line: 363
And befor i did get an error from tpshout and disabled it and got this one above instead.
I don't know if this is the problem or not, but the "name" for each item should be just one word and it would probably be best if you used only letters that are in English. As the instructions say
Quote// 'name' => "", // a unique name for the field. No symbols or spaces
The "name" doesn't show on your form or on the forum entry. It's just something so the script can tell the different fields apart. It can literally be anything, except that you can't use spaces or symbols.
i got it working now, my bad :idiot2:.
I never got an answer if i could fix the code so i could get the:
'type' => "heading",
Bolded on the forums after so it looks like this:
Header Name
question 1
question 2
question 3
Header Name2
question 1
question 2
question 3
i believe it is this code i should change somewere:
$postbody = 'Ansökningen har gjorts av ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br /><br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[OAVSLUTAT] ' . $_REQUEST['charlvl'] . ' ' . $_REQUEST['charspec'] . ' ' . $_REQUEST['charclass'] . ' ' . $_REQUEST['charname'] ,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
Wow this is a really good form, will have to play with it asap.
Thanks JPDeni 8)
Looks like I had missed the question that maviel asked.
Yes, that's the place you would alter it. Change
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br /><br />';
to
if ($field['type'] == 'heading')
$postbody .= '[b]' . $field['caption'] . '[/b]<br /><br />';
ÃŽâ€"i JPDeni..! :)
Very useful script!
Is possible to add an option in specific board/topics so my members can they add an review and posted in the same topic..?
I mean somthing like button in post reply area.
Is that very difficult ..? ???
QuoteIs possible to add an option in specific board/topics so my members can they add an review and posted in the same topic..?
I'm not sure what you mean.
Are you asking if this form can be part of a topic on the forum? If that's what you're asking, I would say that it is conceivably possible, but I wouldn't have any idea of how to do it. You could probably be able to adapt it so that the responses are saved in another database table and then displayed with the article. Or possibly you could put it in a block to appear above a board and then have the reviews below it. But I don't know of a way to add programming to a post in a topic.
But possibly you mean something else. :) If so, I'll need you to try to reword your question.
Thank you for your reply JPDeni, and sorry for my English .. :-\
I ask if is possible to add option in post reply area (Attach photo) like link , menu, and you going to your php article script , write review and the review posted back in the same topic just like continud post but with review layout and infos..
I hope im more clear now.. :)
And something more/else that i thing should help you.
I don't want to create any time new topic for new reviews, but i want an option to my members choose in what topic in specific board the review going as continud post let's say .
I hope that help.. :-X
QuoteI ask if is possible to add option in post reply area (Attach photo) like link , menu, and you going to your php article script , write review and the review posted back in the same topic just like continud post but with review layout and infos..
I don't think so.
Here's what you could do...
Create a board (or child board) for reviews. Create topics in that board for different types of reviews, however you want to divide them up. (Maybe you have a movie review site and there's a separate topic for each movie, for example.)
Create a php block to display on the top of only that board and put your form in that block. Include a drop-down field with the different topic titles for the user to select which topic the review would be posted in. Call that field
topic.
Look for the following section in the code:
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
Change the 'id' line to
'id' => $_REQUEST['topic'] ,
Does this make sense?
Yes, good idea, thank you..! i try to do that, and i tell you if it is work.. ! :) :) :)
But the final code must look like this?
$topicOptions = array(
'id' => $_REQUEST['topic'] ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
I do 1 test now and is not work.. :-\
which place i must put this code..?
And the drop-down field..? you mean somthing like this?
array(
'caption' => "ÃŽâ€¢ÃŽÂºÃÆ'Ãâ,¬ÃŽÂµÃÂμάÄÃâ€°ÃÆ'η",
'name' => "feedback4",
'type' => "select",
'options' => "select,ΣÄο ÃÆ'Éμα,ΣÄο Ãâ,¬ÃÂÃŽÂ¿ÃÆ'ÉÃâ,¬ÃŽÂ¿,ΣÄο ÃÆ'Äομα (Äα ÆÄÅνει),ΣÄο ÃÆ'Äομα (Äα καÄαÃâ,¬ÃŽÂ¹ÃŽÂ½ÃŽÂµÃŽÂ¹)",
'defaultvalue' => "1",
'required' => 1
),
Hmmmm. Maybe it won't work. The select field doesn't give what I was thinking it would. Hmmmm. Give me a day or two and I'll see if I can work it out. I may have to create a different kind of select field.
Quote from: JPDeni on September 23, 2009, 12:30:59 AM
Create a php block to display on the top of only that board and put your form in that block. Include a drop-down field with the different topic titles for the user to select which topic the review would be posted in. Call that field topic.
Look for the following section in the code:
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
Change the 'id' line to
'id' => $_REQUEST['topic'] ,
Does this make sense?
The idea is perfect, the "problem" for my now, is to make the drop-down field to work with topics.. :-X
because i allready have an board with about 700 different topics, and there i want to put option for reviews.
Quote from: JPDeni on September 23, 2009, 01:07:10 AM
Hmmmm. Maybe it won't work. The select field doesn't give what I was thinking it would. Hmmmm. Give me a day or two and I'll see if I can work it out. I may have to create a different kind of select field.
Thank you JPDeni ..!
What i thing.. is possible in 'id' => $_REQUEST['topic'] to add option to select from spesific board all the topics with the url number id? like:
index.php/topic,3984.0.html
index.php/topic,3985.0.html
index.php/topic,3986.0.html
index.php/topic,3987.0.html
And showing the title like "example movie " in drop-down field for 3984 topic.
700?!?!!? :o
I was going to suggest a drop-down list, but that's too many for a drop-down.
Hmmmmm.
Let me think some more. What I came up with won't work for that many items. I have another idea that might work, but I have to think about it a bit. (And I have to make dinner. ;) )
I just saw your latest post. Yes, that's what I was thinking, except that I'm not sure how the URL will work because of the format. I just have to let it work in my brain for a little while.
I can't use the "Search engine friendly URLs", so I can't test it out, but I think that you should be able to just use
'id' => $_GET['topic'] ,
without having to create a field for the topic. Could you check that on your site and see if it works?
Likely you will not want the form to appear on the board index, where all the topic titles are listed. I can give you the code for that, but first I would like to be sure that the code above works.
quote author=JPDeni link=topic=29670.msg247259#msg247259 date=1253670252]
I can't use the "Search engine friendly URLs", so I can't test it out, but I think that you should be able to just use
'id' => $_GET['topic'] ,
without having to create a field for the topic. Could you check that on your site and see if it works?
Likely you will not want the form to appear on the board index, where all the topic titles are listed. I can give you the code for that, but first I would like to be sure that the code above works.
[/quote]
ÃŽâ€"ι JPDeni..! :)
I try with that code
$topicOptions = array(
'id' => $_GET['topic'] ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
but nothing happen.. same action like before..
I just got up :) . I'll try testing it out in a bit.
hmmmm.. nicely bumped thread.
wonder if i could use this as the basis for my custom events fields entry.... :)
Quote from: JPDeni on September 23, 2009, 03:31:01 PM
I just got up :) . I'll try testing it out in a bit.
Ok JPDeni.. :) :) i wait.. :)
Also this is my test forum , take a look if you have time :) and tell my..
http://adultforumgr.freehostia.com
Okay. I think I've got it.
At the beginning of the code, just after
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info;
add
if (isset($_GET['topic'])) {
and at the very end of the code, add
}
(This will prevent the form from showing unless the person is viewing a topic.)
Find
echo '
<form action="' . $scripturl . '?page=' . $_GET['page'] . '" method="post">
Replace it with
$place = $_SERVER['REQUEST_URI'];
echo '
<form action="' . $place . '" method="post">
I've just tested it out and it works fine. :) However (there's always a "however", isn't there?), the user will have to go back to the index and then back to the topic in order to see their post.
I've set up an account for you on my test site so you can see how it works. I'll send you login details by PM so you can test it out.
JP, could you PM those login details as well. I'd like to see what you guys are doing.
ZP
Ok JPDeni..! i already post there.. check it out.. :) :)
ZP, you've got an account already.
http://tester.jpdeni.com/index.php
There's just one board. You can access the form from any topic in the board. You have to go back to the index and then back to the topic in order to see your new post.
EasyRider, I saw your post. You select which topic from the board index. If you only had 30 -- or even 50 -- different topics, I would be able to use a select field with the topics. But with 700 possible topics, that's too many to put into a select list. This is the best way to do it.
Ok..! :) i thing this is the best way to work in all topics..
I go to check it out now and i tell you what happen .. :up:
Quote from: JPDeni on September 23, 2009, 05:09:38 PM
There's just one board. You can access the form from any topic in the board. You have to go back to the index and then back to the topic in order to see your new post.
OK, I see what you are doing. I tried hitting refresh instead of going back to the board index and it just posted the same form again. OK, I can see what you did with this now.
Thanks,
ZP
QuoteI tried hitting refresh instead of going back to the board index and it just posted the same form again.
That's a potential problem and I'm not sure how to get around it. Probably the only thing you can do is to put something in the "thank you" part that displays after the form is submitted. And if there are duplicates, the admin will just have to delete them.
Hey JPDeni finally works great..! :up: :up: :up:
But 1 question.. is there way to not change the post title with the new custom..?
I mean to leave the topic title as was it in any new review post.
And i have a block in portal front page with recent topics (rss) , and i try test preview post, but is not appear the review in latest (recent) topics in front page block.
Maybe is some conflict with the custom title (see first paragraph^^) in topic..? :-X :-X
You can change the post title. Just look at the code.
In the original code, there's a line
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['realname']),
Put whatever you want in there, using the field name in the place of realname and you can delete or change the text that's in there. So, if you had a field name called subject, you would use
'subject' => addslashes($_REQUEST['subject']),
I don't know anything about rss, and, since I don't know what code you're using for the recent topics, I can't tell you how to adjust it for this.
Quote from: JPDeni on September 23, 2009, 05:50:06 PM
QuoteI tried hitting refresh instead of going back to the board index and it just posted the same form again.
That's a potential problem and I'm not sure how to get around it. Probably the only thing you can do is to put something in the "thank you" part that displays after the form is submitted. And if there are duplicates, the admin will just have to delete them.
Would it be possible to make it so that the Submit button causes the page to refresh along with posting the form content? After submitting my entry I refreshed the page and it worked OK for showing the new post.
EDIT: Whoops! Seems to have posted it twice?
http://tester.jpdeni.com/index.php?topic=4.msg19#msg19
JPDeni, If i don't want change the post title..? for example i mean to be like this title:
"Re: Generic Application Form" and not the custom option..
Yeah, Ken. That's the problem. Refreshing shows the post, but also adds another post. If you go to the board index and then back to the topic, then you'll see the post without adding another one.
EasyRider, it looks like I'll have to add some more code. Hang on.
Okay. :)
Change the first line of your code to
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
After
if ($enable_post) { //create new forum post with application
Add
$topic = $_GET['topic'];
$result = db_query("SELECT m.subject
FROM {$db_prefix}messages as m, {$db_prefix}topics as t
WHERE m.ID_TOPIC = $topic
AND t.ID_FIRST_MSG = m.ID_MSG", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$subject = $row['subject'];
mysql_free_result($result);
and then set your subject line to
'subject' => 'Re: ' . $subject,
Great..!! Work..!!! (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg186.imageshack.us%2Fimg186%2F7610%2Fthumbs.gif&hash=8c6baa93f707fb2f9a7a20a6012b6b57f7f28137) (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg186.imageshack.us%2Fimg186%2F7610%2Fthumbs.gif&hash=8c6baa93f707fb2f9a7a20a6012b6b57f7f28137) (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg186.imageshack.us%2Fimg186%2F7610%2Fthumbs.gif&hash=8c6baa93f707fb2f9a7a20a6012b6b57f7f28137) Thank you JPDeni..!!!!
:) There's lots of different stuff you can do with this form. I like try new things and it's interesting to see what different things people come up with that I can figure out.
Nice work JP :)
THX, freddy!
Hey JPDeni, is maybe possible to add some style in the final review..? :) :) (https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg132.imageshack.us%2Fimg132%2F4285%2Flovecz.gif&hash=ba324ff4d9ff10e4af3750f0e9330c068d3a7e31)
Like bold or color text:
""Recruitment application has been made by ... xvxvz
Heading
Name: farkle
Age: 18
Sex: F
Do you like me?: Yes
Comments: should have the original subject line""
Quote from: JPDeni on September 23, 2009, 08:16:12 PM
:) There's lots of different stuff you can do with this form. I like try new things and it's interesting to see what different things people come up with that I can figure out.
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi33.tinypic.com%2Fdmso6r.gif&hash=97cfbbd852878c425a4763f0c8694583b65bde3e)
:)
You can add formatting however you want. Just add BBCode to the post:
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
That will make each line the same, with the caption in bold print. If you want to do different formatting for different lines, it's a little more work.
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
This will just make the Comments caption in red.
I m not sure were put this lines to work.. :-\
I'm sorry. Look for the section:
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 .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
You want to change the $postbody lines.
Thank you JPDeni.. :) i try it once with no success, but is little late in my time zone..
I check it tomorrow again and i tell you what happen.
Good night dear.. :) :) :)
Possibly I was unclear as to what you needed to do, because I made the change and it worked perfectly.
Find
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 .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
and replace it with
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 .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
}
Hi JPDeni. :)
Thank you. I go to check it now.. :up:
The bold caption work perfect..! :) but i can't see the color (red) in text area..
Is possible to add space between the captions..? i mean like this:
Heading
empty space
Name: farkle
Age: 18
Sex: F
Do you like me?: Yes
emty space
Comments: should have the original subject line""
Which code did you enter? I gave you two sets of code earlier. The first only will bold the caption. The second adds the red. (I was showing you different options. :) )
It's possible to format it any way you want. Tell me exactly how you want it formatted and I'll post the code. :)
So, i have to try again to add the correct code.. :)
And i come back to tell you what i thing for the format and tell my if it is possible.
Quote from: JPDeni on September 24, 2009, 04:28:01 PM
Which code did you enter? I gave you two sets of code earlier. The first only will bold the caption. The second adds the red. (I was showing you different options. :) )
It's possible to format it any way you want. Tell me exactly how you want it formatted and I'll post the code. :)
I enter the second code with red color in caption text area option. But not any red color print in post. Only bold captions everywhere..
Odd. It works perfectly on my site.
I don't know what it could be ... unless ... is it possible that you do not allow the color tag in your forum? That's the only reason I can think of that it wouldn't show.
out of interest... is there any permission checking on the topic posting option ?
if i use this then the topic will be sent to a private board before being approved and moved to a public board.
so if the submitter does not have access to the private board will it still post the message ?
Hi JPDeni :) my original code is this:
(i do something wrong..? ???)
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
// Guests can't fill out the form
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 = "ÃŽÂ ÃÂÃŽÂÃâ,¬ÃŽÂµÃŽÂ¹ να είναι ÃÆ'Ã…μÃâ,¬ÃŽÂ»ÃŽÂ·ÃÂÉμÎÂνα ÃÅ'λα Äα Ãâ,¬ÃŽÂµÃŽÂ´ÃŽÂ¯ÃŽÂ± για να είναι ÃŽÂγκÃ…ÃÂη η κÃÂιÄική ÃÆ'αÂ.";
$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
// ),
// );
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
$fielddef =
array(
array(
'caption' => "ΠληÃÂοÆοÃÂίε ΣÃ…νάνÃâ€žÃŽÂ·ÃÆ'ηÂ",
'name' => "heading",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "ÃŽâ€"μεÃÂομηνία ÃÆ'Ã…νάνÃâ€žÃŽÂ·ÃÆ'ηÂ",
'name' => "date",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "ΣÃ…μÃâ,¬ÃŽÂµÃÂιÆοÃÂά Ãâ,¬ÃÂακÄοÃÂείοÃ…",
'name' => "feedback1",
'type' => "select",
'options'=> "select,κακη,μεÄÃÂια,καλη",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ÃŽÂ¥Ãâ,¬ÃŽÂ·ÃÂÃŽÂµÃÆ'ίε ΚοÃâ,¬ÃŽÂλαÂ",
'name' => "heading",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "ΕμÃâ€ ÃŽÂ¬ÃŽÂ½ÃŽÂ¹ÃÆ'η (Ãâ,¬ÃÂÃÅ'ÃÆ'ÉÃâ,¬ÃŽÂ¿)",
'name' => "feedback5",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ΕμÃâ€ ÃŽÂ¬ÃŽÂ½ÃŽÂ¹ÃÆ'η (ÃÆ'Îμα)",
'name' => "feedback5",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "Γενική ÃÆ'Ã…μÃâ,¬ÃŽÂµÃÂιÆοÃÂά",
'name' => "feedback6",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ΕÃâ,¬ÃŽÂ¹ÃŽÂºÃŽÂ¿ÃŽÂ¹ÃŽÂ½Ã‰Î½Î¯Î±",
'name' => "feedback7",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ÃŽâ€ÃŽÂ¹ÃŽÂ¬ÃŽÂ¸ÃŽÂµÃÆ'η ÃÆ'Äο ÃÆ'εξ/ÃÆ'Ã…μμεÄοÇή",
'name' => "feedback8",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ΠεολειÇία",
'name' => "feedback2",
'type' => "select",
'options' => "select,ÃŽÅ"ε Ãâ,¬ÃÂοÆÅλακÄικο,ΧÉÃÂι Ãâ,¬ÃÂοÆÅλακÄικο",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "A-level (Ãâ,¬ÃÂÉκÄικÃÅ')",
'name' => "feedback3",
'type' => "select",
'options' => "select,ναι,οÇι",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ÃŽâ€¢ÃŽÂºÃÆ'Ãâ,¬ÃŽÂµÃÂμάÄÃâ€°ÃÆ'η",
'name' => "feedback4",
'type' => "select",
'options' => "select,ΣÄο ÃÆ'Éμα,ΣÄο Ãâ,¬ÃÂÃŽÂ¿ÃÆ'ÉÃâ,¬ÃŽÂ¿,ΣÄο ÃÆ'Äομα (Äα ÆÄÅνει),ΣÄο ÃÆ'Äομα (Äα καÄαÃâ,¬ÃŽÂ¹ÃŽÂ½ÃŽÂµÃŽÂ¹)",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "ΣÇÎÂÃÆ'η αÃâ,¬ÃÅ'ÃŽÂ´ÃŽÂ¿ÃÆ'ηÂ/ÄιμήÂ",
'name' => "check",
'type' => "select",
'options' => "select,3,4,5,6,7,8,9,10",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "Θα ξαναεβλεÃâ,¬ÃŽÂµÃ‚ Äην κοÃâ,¬ÃŽÂµÃŽÂ»ÃŽÂ±?",
'name' => "feedback",
'type' => "select",
'options' => "select,ÃŽÂαι,ΟÇι,MÃâ,¬ÃŽÂ¿ÃÂει, δεν εÇÉ αÃâ,¬ÃŽÂ¿Ãâ€ ÃŽÂ±ÃÆ'ÃŽÂ¹ÃÆ'ει ακομα..",
'defaultvalue' => "1",
'required' => 1
),
array(
'caption' => "Overall",
'name' => "comments",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
);
$topicOptions = array(
'id' => $_REQUEST['topic'] ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
$thanks_text = "ΕÅÇαÃÂÃŽÂ¹ÃÆ'ÄοÃ…με για Äην κÃÂιÄικη! ";
//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=2;
//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 = 'Application';
$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
$topic = $_GET['topic'];
$result = db_query("SELECT m.subject
FROM {$db_prefix}messages as m, {$db_prefix}topics as t
WHERE m.ID_TOPIC = $topic
AND t.ID_FIRST_MSG = m.ID_MSG", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$subject = $row['subject'];
mysql_free_result($result);
$postbody = 'ΕÅÇαÃÂÃŽÂ¹ÃÆ'ÄοÃ…με για Äην κÃÂιÄικη ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => 'Re: ' . $subject,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => $_GET['topic'] ,
'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 a *.</div>'; }
$place = $_SERVER['REQUEST_URI'];
echo '
<form action="' . $place . '" 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; font-weight:bold;">' .
$field['caption'] . '
</TD>
</TR>';
}
else {
// How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
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="6" cols="50">';
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>';
}
}
Quote from: ed_m on September 25, 2009, 11:16:49 AM
out of interest... is there any permission checking on the topic posting option ?
if i use this then the topic will be sent to a private board before being approved and moved to a public board.
so if the submitter does not have access to the private board will it still post the message ?
ed_m,
The original intent of this code was as an application form that could be filled out by a member that would start a new topic in a board. The board need not be visible to the poster but it could just as easily be visible. You set the board that the new topic is placed into in the code. There is also a way in the code to send the Admin an EMail when the form is filled out and submitted.
ZarPrime
EasyRider, you have the code right. I don't know what the problem could be. I'm sorry.
This bit....
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
Does he actually have a field called "Comments" ?
The way I read it the red will only display if the field is specifically named 'Comments'...so I am thinking he would need to test for each and every heading type that he wants to be red.
Hmmm :-\
Good call, freddy! It didn't even occur to me.
EasyRider, you need to change the caption to match the field you have. It would be, I guess
elseif ($field['caption'] == 'Overall')
*twiddles thumbs*
ed_m, ZarPrime answered your question. Or did you have another one?
Quote from: JPDeni on September 25, 2009, 04:22:04 PM
Good call, freddy! It didn't even occur to me.
EasyRider, you need to change the caption to match the field you have. It would be, I guess
elseif ($field['caption'] == 'Overall')
Great !!! Works !!! :) :) :) :) :up: :up: :up: :up: :up:
Quote from: JPDeni on September 25, 2009, 04:43:22 PM
ed_m, ZarPrime answered your question. Or did you have another one?
oh yes sorry.. well in that case i just wanted to feel involved :)
you've saved me alot of dull form creation.
Quotewell in that case i just wanted to feel involved
LOL. :D
Quoteyou've saved me alot of dull form creation
I know what you mean. It is tedious.
Another one question
is possible to add empty space between captions,
and put bold & (or) custom color..?
So the finall (print ) post is like this:
Heading
Name: farkle
Age: 18
Sex: F
Another Heading
Do you like me?: Yes
Comments: should have the original subject line""
Hey JPDeni.. if is "problem" for you, is ok..
I'm just total irrelevant about php code and maybe i stress you with all this questions.. sorry.. :-\ :-\ :-\
No, that's okay. I think I got it figured out. Or, rather, freddy888 did. :)
Did you make the change I posted?
freddy888 did it..? sorry i didn't see it..
1' to check it. :)
Actually, I didn't see your post with the question.
I need you to tell me exactly what you want your final output to look like, using your fields and not mine.
Ok, i thing like this is perfect:
Ευχαριστούμε για την κριτική Easyrider
Overall: TEST REVIEW
Πληροφορίες Συνάντησης
Ημερομηνία συνάντησης: 1234567
Διάρκεια συνάντησης: 3 ώρες
Χωρος: Στο χωρο μου
Κόστος €: 000
Συμπεριφορά του γραφείου: κακή
Εντυπώσεις Γενικά
Εμφάνιση (πρόσωπο): 4
Εμφάνιση (σώμα): 4
Συμπεριφορά: 3
Επικοινωνία: 3
Service
Φιλάει: Καθόλου
Πεολειχία: Με προφυλακτικο
A-level (πρωκτικό): ναι
Εκσπερμάτωση: Στο προσωπο
Εξτρά εκσπερματώσεις: Μόνο μια φορά
Διάθεση στο σεξ/συμμετοχή: 9
Σχέση απόδοσης/τιμής: 9
Θα ξαναέβλεπες την κοπέλα?: Mπορεί
Σχόλια: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus id urna ut arcu mattis convallis. Nam consequat bibendum ullamcorper. Fusce malesuada commodo nibh, sit amet adipiscing enim commodo eget. Aliquam erat volutpat. Integer id mi urna. Curabitur egestas urna at turpis interdum at mollis odio lobortis. Vivamus eu urna tellus. Nulla interdum cursus elit. Mauris interdum urna at lorem fermentum mollis. Vivamus non arcu sed magna bibendum commodo quis vitae sem. Aliquam erat volutpat. Curabitur pellentesque, lectus ut vestibulum dapibus, quam ligula euismod leo, vitae auctor ligula leo vitae nisi. Curabitur dapibus arcu justo, sed lacinia quam. Curabitur eleifend egestas est, at eleifend eros dignissim at. Pellentesque vel nunc et dolor iaculis dapibus eu ut tellus. Suspendisse nisi mauris, rutrum in gravida id, viverra at dolor. Curabitur id volutpat tellus. Vivamus enim nulla, feugiat eu molestie et, ornare id tortor.
I add and the original code if that help.!
I'm not sure about all this because I don't read Greek (I'm assuming Greek because that's what the letters look like) and the text file shows different letters for the captions than you have. I'll try to figure out what's going on, but I'm not going to guarantee anything. :)
Because of the problems with the text, I won't post the whole code, but just the code you need to change.
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '<br />' . $field['caption'] . '<br /><br />';
elseif ($field['name'] == 'comments')
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
elseif ($field['name'] == 'overall')
$postbody .= $field['caption'] . ': [b]' . $_REQUEST[$field['name']] . '[/b]<br />';
else
$postbody .= '[b]' . $field['caption'] . ': [color=red]' . $_REQUEST[$field['name']] . '[/color][/b]<br />';
}
Ok! and.. were exactly i m gone put this ^^^ code..?? ???
In the same place you put the other code.
Here's the whole section, but there's a line in there that you'll have to change back to your language.
if ($enable_post) { //create new forum post with application
$topic = $_GET['topic'];
$result = db_query("SELECT m.subject
FROM {$db_prefix}messages as m, {$db_prefix}topics as t
WHERE m.ID_TOPIC = $topic
AND t.ID_FIRST_MSG = m.ID_MSG", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$subject = $row['subject'];
mysql_free_result($result);
$postbody = 'Åõ÷áñéóôïýìå ãéá ôçàêñéôéêÞ ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '<br />' . $field['caption'] . '<br /><br />';
elseif ($field['name'] == 'comments')
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
elseif ($field['name'] == 'overall')
$postbody .= $field['caption'] . ': [b]' . $_REQUEST[$field['name']] . '[/b]<br />';
else
$postbody .= '[b]' . $field['caption'] . ': [color=red]' . $_REQUEST[$field['name']] . '[/color][/b]<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => 'Re: ' . $subject,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => $_GET['topic'] ,
'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);
}
OKK..!! i try it now..!! :up:
just PERFECT!! !! :) :) :) :) :)
i attach screen about what i print and what i thing is missing. headers in bold, and space between last caption and comments.
I thought I had done that. I guess not. :)
if ($enable_post) { //create new forum post with application
$topic = $_GET['topic'];
$result = db_query("SELECT m.subject
FROM {$db_prefix}messages as m, {$db_prefix}topics as t
WHERE m.ID_TOPIC = $topic
AND t.ID_FIRST_MSG = m.ID_MSG", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
$subject = $row['subject'];
mysql_free_result($result);
$postbody = 'Åõ÷áñéóôïýìå ãéá ôçàêñéôéêÞ ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '<br />[b]' . $field['caption'] . '[/b]<br /><br />';
elseif ($field['name'] == 'comments')
$postbody .= '<br />[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
elseif ($field['name'] == 'overall')
$postbody .= $field['caption'] . ': [b]' . $_REQUEST[$field['name']] . '[/b]<br />';
else
$postbody .= '[b]' . $field['caption'] . ': [color=red]' . $_REQUEST[$field['name']] . '[/color][/b]<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => 'Re: ' . $subject,
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => $_GET['topic'] ,
'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);
}
I HAVE ONLY 1 THING TO SAY: THANK YOUUUUUUU JPDeni..!!!!!!!!!!!!
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi37.tinypic.com%2Fei81nb.jpg&hash=8d523977216894cd5c03ab013c09cf72939930c8)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi34.tinypic.com%2F2rghkw7.jpg&hash=961028ce36d367c4b21dce65f3e2f06bfd77e171)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi38.tinypic.com%2F2niur8g.jpg&hash=b1f37f2bad307ba068de09be81a8000b590e5177)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F30w5dn6.jpg&hash=75cd2b9e4f3488b0506e0602603163d7e0860a67)
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi35.tinypic.com%2F303l3dw.jpg&hash=276eec25a82e22bd0d6ba5a9d7343a1c53a7823e)
:D
You're welcome. I'm glad I was able to help.
Brilliant job JP ;D
little additional question for me, i'm adapting this with two purposes:
1 - events thread creation & submission to the smf calendar with custom fields
2 - custom events search based on form input
in the first case the form data is used with an INSERT statement and the later case with a SELECT.
i'm a little concerned on security and how best to add extra validation to some of the fields to prevent SQL insertion.
if i was feeling fancy i'd suggest an extra parameter with each field for a string of illegal characters that is checked at the same location as the madatory fields.
any suggestions / tips / tricks ?
You might want to take a look at /Sources/Post.php, function createPost to see how SMF deals with security.
There's an SMF function I use to clean up passed variables; you might want to take a look at that too :
cleanRequest... (http://support.simplemachines.org/function_db/index.php?action=view_function;id=359)
Really whenever you insert data to the DB you want to be using that.
Also it's a good idea to check the session before you do anything too :
checkSession... (http://support.simplemachines.org/function_db/index.php?action=view_function;id=404)
If you are worried by HTML being inserted you can use this PHP function :
strip_tags... (http://www.php.net/manual/pl/function.strip-tags.php)
There's probably a whole host of other solutions too - I would try Google and see what methods other people suggest to protect from SQL injection.
If you're using SMF's db functions everything is already cleaned for you.
thanks.. i'll do some digging.
http://www.simplemachines.org/community/index.php?topic=119652.0
and
http://www.smfmods.org/wiki/Security_practices
are my intitial hits.
i've yet to see any info on whether db_query input is cleaned or not.
Quotei've yet to see any info on whether db_query input is cleaned or not.
I'm not sure either, but I don't doubt IchBin. I use it because in the SMF Coding Guidelines it says use it - though docs often go out of date, though maybe they mean for regular db queries rather than the SMF function.
You can take a look for yourself :
http://www.simplemachines.org/community/index.php?topic=159824.0
There's also the practice of casting number to integers too, which is mentioned in the docs.
ed_m, this is code from db_query:
// First, we clean strings out of the query, reduce whitespace, lowercase, and trim - so we can check it over.
if (empty($modSettings['disableQueryCheck']))
{
$clean = '';
$old_pos = 0;
$pos = -1;
while (true)
{
$pos = strpos($db_string, '\'', $pos + 1);
if ($pos === false)
break;
$clean .= substr($db_string, $old_pos, $pos - $old_pos);
while (true)
{
$pos1 = strpos($db_string, '\'', $pos + 1);
$pos2 = strpos($db_string, '\\', $pos + 1);
if ($pos1 === false)
break;
elseif ($pos2 == false || $pos2 > $pos1)
{
$pos = $pos1;
break;
}
$pos = $pos2 + 1;
}
$clean .= ' %s ';
$old_pos = $pos + 1;
}
$clean .= substr($db_string, $old_pos);
$clean = trim(strtolower(preg_replace(array('~\s+~s', '~/\*!40001 SQL_NO_CACHE \*/~', '~/\*!40000 USE INDEX \([A-Za-z\_]+?\) \*/~'), array(' ', '', ''), $clean)));
// We don't use UNION in SMF, at least so far. But it's useful for injections.
if (strpos($clean, 'union') !== false && preg_match('~(^|[^a-z])union($|[^[a-z])~s', $clean) != 0)
$fail = true;
// Comments? We don't use comments in our queries, we leave 'em outside!
elseif (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
$fail = true;
// Trying to change passwords, slow us down, or something?
elseif (strpos($clean, 'sleep') !== false && preg_match('~(^|[^a-z])sleep($|[^[a-z])~s', $clean) != 0)
$fail = true;
elseif (strpos($clean, 'benchmark') !== false && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0)
$fail = true;
// Sub selects? We don't use those either.
elseif (preg_match('~\([^)]*?select~s', $clean) != 0)
$fail = true;
if (!empty($fail))
{
log_error('Hacking attempt...' . "\n" . $db_string, $file, $line);
fatal_error('Hacking attempt...', false);
}
}
Looks like there's checking there.
Hi Deni ! :) :)
Is possible to add a simple date picker in some field..? for example like this one:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi36.tinypic.com%2F68xxc5.png&hash=244a0b1137d57a97dd9d1b80965c74bd9de91e5a)
or something more simple.. :-X
I add the code in zip attachment !
I wouldn't know how to do it, I'm afraid. This is way beyond the capability of my simple form.
No problem deni ! I knew it was very difficult..
But you already done so many things about.. !
Anwy, thank you dear !! :) :) :)
Noted :-\
Quote
I'm having troubles with this part of the code in the latest "SMF 2.0"
This code is only to be used with TinyPortal and TinyPortal does not yet work with SMF 2.0. Therefore, you need to find other code to use. Or go back to SMF1.10 and TinyPortal.
How would we make the posted thread a different color then the questions asked. and how to space the questions out
Quote from: JPDeni on May 23, 2009, 11:04:28 PM
This is designed for those who wish to make an application form for their site.
| type: | php article |
| author: | JPDeni |
| name: | Application Form |
How would we make the posted thread a different color then the questions?
| version: | .1 |
| date: | 16 Apr 2009 |
| discussion topic: | http://www.tinyportal.net/index.php/topic,9840.0.html (sort of) |
| description: |
- Creates a form to be filled out by prospective members
- Form fields are defined within the text, to include text, textarea, select, radio and checkbox fields
- Results can be emailed to an admin, posted to a specified board or both
|
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info;
// Guests can't fill out the form
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 = "Put whatever introduction you want to appear at the top of the form here. You can add html. Be careful with quotation marks.";
$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' => "Heading",
'name' => "heading",
'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' => "13,14,15,16,17,18,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' => "Sex",
'name' => "sex",
'type' => "radio",
'options' => "M,F",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Do you like me?",
'name' => "like",
'type' => "checkbox",
'options' => "Yes",
'defaultvalue' => "Yes",
'required' => 0
),
array(
'caption' => "Comments",
'name' => "comments",
'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=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 = 'Application';
$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 = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['realname']),
'body' => addslashes($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 a *.</div>'; }
echo '
<form action="' . $_SERVER['REQUEST_URI'] . '" 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="right">';
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="4" cols="40">';
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>';
}
}
23 Sep 2009 -- Minor alteration to make the script work in blocks as well as articles.
Sorry for my double post But I am in need of some help. I am trying to make the posted form text a different color then the questions asked. Make it easier to read this way. And maybe put a space between each question asked as well. I figured it would have to be in here somewhere
/ How each field is displayed in the table
echo '
<TR class ="' . $bg . '">
<TD align="right">';
if ($field['required'] == 1) { echo '* '; }
echo $field['caption'] . ':
</TD>
<TD align="left" style="color: red">';
// 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="4" cols="40">';
echo $fieldvalue[$field['name']];
echo '</' . 'TEXTAREA>';
}
// Finish off the row
echo '
</TD>
</TR>';
}
Anyhelp will be greatly appreciated.
Quoteto make the posted form text a different color then the questions asked
Is this on the form or in the post?
It seems that you're asking about the post, but the code you posted is the printout of the form.
Either way, All I want colored is the answers when they post. And to have them spaced out accordingly
http://darknesscalls.net/index.php?topic=8.0
see how it looks cluttered?
No, you aren't concerned with "either way." You want it in the post. Here is the section that deals with the format of the post:
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
So, let's say you wanted the caption to be red.
else
$postbody .= '[color=red]' . $field['caption'] . '[/color]: ' . $_REQUEST[$field['name']] . '<br />';
You can adjust the printout to look like you want, using bbc code.
To be honest, the thing that makes your post look most crowded is that you don't have any spaces between the numbers and the words in your captions. You will have to add the spaces in the configuration section.
If you want to have multiple spaces show up, you may need to do a little bit of other tweaking. But it will likely improve by your adding spaces after your numbers and adding color to the captions.
Hello JPDeni :) and thank you for an amazing code.
I've done my share of editing and tuning your code for my liking.
I've also been trying to unlock a feature that could be possible but since i know a little php but nothing about how to command the forum features.
I'd like to add the ability to create a poll with every poll that maybe says ..
"Accept?" with a "Yes" & a "No" as possible answers, obviously if its possible to make dynamic question and answers it would be even better.
That's my application form Current APP (http://sanctumguild.org/index.php?page=2).
Thank you :)
//narl!
QuoteI'd like to add the ability to create a poll with every poll that maybe says ..
"Accept?" with a "Yes" & a "No" as possible answers, obviously if its possible to make dynamic question and answers it would be even better.
I don't understand what you want. You can make radio buttons with the code as it is. If you give me more detail and why you want it, I'll see if I can help you get what you want.
The Forum post it creates :), i'd like to have it as a poll instead of being a normal forum post.
Oh. I see. I'll have to look at how polls are created in SMF.
I'll give you the edits here and also change the code in the first post.
Change the first line
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info;
to
global $sourcedir, $ID_MEMBER, $context, $scripturl, $user_info, $db_prefix;
After
//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=2;
(your options may be different)
Add
// Poll options
$add_poll = 1; // 0 = No poll; 1 = add poll
$poll_question = "Accept this member?"; // This is the question for the poll
$expireTime = 0; // Change this to the number of days you want the poll to run
$hideResults = 0; // 0 = Results are always visible; 1 = Can see results only after voting; 2 = Can see results only after poll expires
$changeVote = 0; // 0 = Voters can not change their votes; 1 = Voters can change their votes
$poll_choices = array('Yes','No'); // The options listed for the poll
After
if ($enable_post) { //create new forum post with application
Add
if ($add_poll === 1) {
$posterName = $context['user']['name'];
if ($expireTime > 0)
$expireTime = time() + $expireTime * 3600 * 24;
db_query("
INSERT INTO {$db_prefix}polls
(question, hideResults, maxVotes, expireTime, ID_MEMBER, posterName, changeVote)
VALUES ('$question', '$hideResults', '1', '$expireTime', '$ID_MEMBER', '$posterName', '$changeVote')", __FILE__, __LINE__);
$ID_POLL = db_insert_id();
// Create each answer choice.
$i = 0;
$setString = '';
foreach ($poll_choices as $option)
{
$setString .= "
('$ID_POLL', '$i', SUBSTRING('$option', 1, 255)),";
$i++;
}
db_query("
INSERT INTO {$db_prefix}poll_choices
(ID_POLL, ID_CHOICE, label)
VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
}
else
$ID_POLL = null;
Change
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
to
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => $ID_POLL,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
Thank youuuuuuuuuuuuuuuuuu!
;) :up:
Awesome cakes!
any option to get user can upload image?
like <form id="Upload" action="<?php echo $uploadHandler ?>" enctype="multipart/form-data" method="post">
<h1>
Upload form
</h1>
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>">
</p>
<p>
<label for="file">File to upload:</label>
<input id="file" type="file" name="file">
</p>
<p>
<label for="submit">Press to...</label>
<input id="submit" type="submit" name="submit" value="Upload me!">
</p>
</form>
or with bbc imagelink?
No. That would be beyond the capability of this mod.
how about using bbc image?
If you want to add that, give it a try. Play around with it. Experiment.
Off the top of my head, I don't know how to do it, but maybe you can work it out.
Very Nice job!! this is perfect!
but one thing,
is there anyway I could make it underline or bold the headings within the post?
thanks!
Obviously not perfect ;-)
Look for
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
To make the headings bold, change it to
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '[b]' . $field['caption'] . '[/b]<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
To make the heading underlined change it to
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= '[u]' . $field['caption'] . '[/u]<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
You can add any BBC code within quotation marks that you want.
:D thank you very much I was messing around with that but i guess i didnt have the tags within the quotes like i was supposed to, your da best!
You're welcome. :) Sometimes it just takes an example to see how it's done. Now that you've seen the pattern, you'll be able to do anything you want.
Hi JPDeni and big thank you for this useful tool. :)
1 question.
Is possible to appear the review post in front page block..?
I mean to appear both in normal topic, and print also one post in first page block.
Like rss block option.. ???
You can display a post from a topic in a block. You would just need to know the post number. Or you could post the first post from the most recent topic from a given board, which I suppose would be the closest thing to an rss feed. That would be something completely separate from this code, though.
I see. thank you for your answer.
Until now the form print new review post only in topic i choose. This topic have not only reviews but normal posts also.
I wand to appear only the review post in front page (block) and also in his topic as is now, at once.
is that possimple..? :)
You have a board.
//board id to which the application should be posted
$board_id=2;
In this board are topics, which are created by the script. The first post in each topic is the results of the form. Right?
It is possible that you have other topics in this board. Do you have other topics in this board or are all of the topics only the ones created by the form? That will determine what code I give you.
Not exactly. You make edit in this form to add the review form in existing topic. that is the different.
Look in this post
http://www.tinyportal.net/index.php?topic=29670.msg247281#msg247281
Okay. The code originally was supposed to do what I said. When the form is submitted a new topic is made, with the results at the top so that the rest of the topic is people discussing the form results. But things have changed.
I'll have to try out the idea I have first. It won't be done until tomorrow -- maybe later. Just to let you know what I have in mind, it would be changing the form code so it writes the same post to the body of the block when it writes it to the forum.
Thank you JPDeni! await for. :) :)
hey does this work with rc3 and latest tp? im getting "You must be logged in before you can apply. " even as admin logged in
Quotedoes this work with rc3 and latest tp?
Probably not. I haven't looked at the code for a very long time and I haven't looked closely at the changes for RC3. It might work with SMF1.whatever and the newest TP, but it's unlikely that it would work with the changes that they've put into SMF2.
Quote from: JPDeni on June 03, 2010, 01:27:28 AM
Quotedoes this work with rc3 and latest tp?
Probably not. I haven't looked at the code for a very long time and I haven't looked closely at the changes for RC3. It might work with SMF1.whatever and the newest TP, but it's unlikely that it would work with the changes that they've put into SMF2.
:( any chance of an rc3 version of this :D ?
Quoteany chance of an rc3 version of this
Not from me, I'm afraid. I started making changes to work with RC2 and then SMF made so many changes that all the work I'd done was completely useless. I don't want to waste more time, so I'm not going to work with SMF2 until the actual release.
If anybody else wants to work with it, be my guest.
raxavier69,
I have a version of JPDeni's Form working with SMF 2.0 RC3 and the latest version of TinyPortal but it has some things in it that I would rather remove before posting it. If you give me until this weekend or so, when I will have more time to look at it, I'll post it, with JPDeni's permission of course.
ZarPrime
Go ahead, ZP.
Quote from: ZarPrime on June 03, 2010, 04:06:50 AM
raxavier69,
I have a version of JPDeni's Form working with SMF 2.0 RC3 and the latest version of TinyPortal but it has some things in it that I would rather remove before posting it. If you give me until this weekend or so, when I will have more time to look at it, I'll post it, with JPDeni's permission of course.
ZarPrime
Sweet ty very, cant wait :) cheers m8
raxavier69,
OK, the code below will work for SMF 2.0 RC3 and TinyPortal 1.0 beta 5 (all versions). However, be aware that it isn't perfect right now. There are some other things that could be done with it. Also, the polls that were put in by JPDeni are not enabled in this version, mainly because I haven't had a chance to look to see how to do that in SMF 2.0. Be sure to set the "$board_id=x;" for the correct board you want the new topic to be created in.
FWIW, prior to TP 1.0 beta 5 coming out, I had been working on a Support Form based on JPDeni's code for our use here in the event that we were swamped with support questions. Because we never got swamped with these questions, I never finished the code but, with JPDeni's help, I did make some nice enhancements to it. For instance, instead of the subject of the topic being automatically generated, I had put in a way for the Form user to type in a subject. Also, I changed some of the formatting and removed slashes when the user types a word with apostrophe's in it.
Try this code out, and if it works for you, we will post a new topic in the new Block Code Snippets board, and I will include the code for the TinyPortal Support Form that I had been working on as an example.
ZarPrime
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 apply.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "Put whatever introduction you want to appear at the top of the form here. You can add html. Be careful with quotation marks.";
$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' => "Heading",
'name' => "heading",
'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' => "13,14,15,16,17,18,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' => "Sex",
'name' => "sex",
'type' => "radio",
'options' => "M,F",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Do you like me?",
'name' => "like",
'type' => "checkbox",
'options' => "Yes",
'defaultvalue' => "Yes",
'required' => 0
),
array(
'caption' => "Comments",
'name' => "comments",
'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=2;
// Poll options
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version
//$add_poll = 1; // 0 = No poll; 1 = add poll
//$poll_question = "Accept this member?"; // This is the question for the poll
//$expireTime = 0; // Change this to the number of days you want the poll to run
//$hideResults = 0; // 0 = Results are always visible; 1 = Can see results only after voting; 2 = Can see results only after poll expires
//$changeVote = 0; // 0 = Voters can not change their votes; 1 = Voters can change their votes
//$poll_choices = array('Yes','No'); // The options listed for the poll
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version
//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 = 'Application';
$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
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version /////
// if ($add_poll === 1) {
// $posterName = $context['user']['name'];
// if ($expireTime > 0)
// $expireTime = time() + $expireTime * 3600 * 24;
// db_query("
// INSERT INTO {$db_prefix}polls
// (question, hideResults, maxVotes, expireTime, ID_MEMBER, posterName, changeVote)
// VALUES ('$question', '$hideResults', '1', '$expireTime', '$ID_MEMBER', '$posterName', '$changeVote')", __FILE__, __LINE__);
// $ID_POLL = db_insert_id();
//
// // Create each answer choice.
// $i = 0;
// $setString = '';
// foreach ($poll_choices as $option)
// {
// $setString .= "
// ('$ID_POLL', '$i', SUBSTRING('$option', 1, 255)),";
// $i++;
// }
//
// db_query("
// INSERT INTO {$db_prefix}poll_choices
// (ID_POLL, ID_CHOICE, label)
// VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
//
// }
// else
// $ID_POLL = null;
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version /////
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
else
$postbody .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['realname']),
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version /////
// $topicOptions = array(
// 'id' => 0 ,
// 'board' => $board_id,
// 'poll' => $ID_POLL,
// 'lock_mode' => null,
// 'sticky_mode' => null,
// 'mark_as_read' => true,
// );
///// ZP Edit - Poll options disabled in SMF 2.0 RC3/TP 1.0 beta 5 version /////
///// Above replaced by the following until polls done
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => null,
'lock_mode' => null,
'sticky_mode' => null,
'mark_as_read' => true,
);
///// Above replaced by the above until polls done
$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 a *.</div>'; }
echo '
<form action="' . $_SERVER['REQUEST_URI'] . '" 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="right">';
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="4" cols="40">';
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>';
}
}
TY ZP,
ill try out the code tomorrow, im not much of a coder so it might take be a bit to get it out the way i want it. General question, you think i can use dreamweaver to include images in it and align it? or is hard coded the way it is?
once again tyvm and will let you know how it works tomorrow.
Side note, any way of making the post outcome be posted in a place where that user usually cannot post? or it is limited to users permissions?
also is this what i need to stick in for a reply for users who are of member group x,y,z?
if ($context['user']['id'] == 0)
echo 'You must be logged in before you can apply.';
elseif ($context['user']['id'] == x,y,z)
echo 'You are already a member.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
or i need elseif for each one?
also how can i insert image into the top of the form regardless of member group? i tried img src but big error
Quote from: raxavier69 on June 07, 2010, 01:12:21 AM
Side note, any way of making the post outcome be posted in a place where that user usually cannot post? or it is limited to users permissions?
Yes, you can set the Board for the post to go into that the member can't see so that only Members who can view that Board will see the post, permission based. In other words, only members who have permission to see that Board will see the topic created.
Quote from: raxavier69 on June 07, 2010, 01:12:21 AM
also is this what i need to stick in for a reply for users who are of member group x,y,z?
if ($context['user']['id'] == 0)
echo 'You must be logged in before you can apply.';
elseif ($context['user']['id'] == x,y,z)
echo 'You are already a member.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
or i need elseif for each one?
I'm not sure what you are trying to do there. If you are trying to limit which MemberGroups can use the form, simply place this article into a Category by itself and then set what MemberGroups can see the Category.
Quote from: raxavier69 on June 07, 2010, 01:12:21 AM
also how can i insert image into the top of the form regardless of member group? i tried img src but big error
The Support Form I was working on actually has an image that I put into the code. In essence, you'd place this in the code to be displayed above the form. Something like this should work ...
Find this ...
$intro_form = "Put whatever introduction you want to appear at the top of the form here. You can add html. Be careful with quotation marks.";
and change to this (or something similar) ...
$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/tp-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>";
It's just standard html though you need to be careful of quotes (just escape them with a backslash ~ \). Change the code to your own and the image link near the top to your own as well. You'd do the same thing for the "$thanks_text" only with different code.
ZarPrime
You've learned very well, ZP. :smitten:
Thanks JPDeni. :smitten: :D My mentor has been an excellent instructor. IMHO, I have learned from the best. ;)
ZarPrime
Alright now... that's enough of that mushiness! :2funny:
j/k JP & ZP, you both do great work. O0
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?
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 got fieldmaster to help thanks :) looks great. will post how it looks in a bit.
YAY!!
looks hot thanks for all the help
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg641.imageshack.us%2Fimg641%2F9499%2Fformt.png&hash=17b93c3d825a60b38d603fb3b6f760e75ff7f19e)
only thing is the check box i tried yes,no,maybe and yes;no;maybe and still didnt work. maybe its just me
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.
ah ty :)
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 :)
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>';
}
}
nvm tp error
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
So I finally got around to actually putting this into practice!
But I'm having a problem, it still makes everything bold, but I want each response to be indented and bulleted. It posts the code itself, but doesn't cause it to appear correctly. If I click modify and preview, it's okay...it seems like something from the form to the post is going awry. Any ideas?
Just in case it helps, the line in question is:
$postbody .= '[list][b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
I should also note that if anyone can help me figure out how to make them numbered like how RaXavier did, that would be awesome. :)
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 have an account on our site before you can apply.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "So you've decided you want to join The Angels Of Armageddon. Great! Just keep the following in mind when applying:<br><br><b>1.</b> Be involved in the forums and be active on the server as much as possible. This shows us that you're an active part of the community and are serious about joining, and will help your application more than you might think!<br><b>2.</b> Having a mic is a requirement to join. We may be willing to make exceptions for extreme cases, and you can make your case in the comments of your app.<br><br><b>Approval Process</b>:<br>Upon posting your application, a forum post will be made in the Applications Section of the board. In your post, anyone may comment and/or vote, though we will only count votes from members, and if we look for input outside of the clan, only our regulars will be taken into consideration. It's best to have been playign with us long enough that we know who you are, it's hard to want you to join us if we don't know you.<br><br>Once your application has been received, you must garner a 'yes' vote from at least 60% of the Joint Chiefs Of Staff. At that point your status as a member will be either accepted or rejected by Bloodlvst (very rarely will you actually be rejected), and you will officially be a member and be given tags. You may not wear tags until all of this has occured. <br>";
$thanks_text = "Thanks for applying! You can check out the progress of your application in the Applications Section.";
// 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 On Server",
'name' => "nickname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Real Name",
'name' => "realname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Location",
'name' => "location",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Age",
'name' => "age",
'type' => "select",
'options' => "13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40+",
'defaultvalue' => "16",
'required' => 1
),
array(
'caption' => "Ping On Server",
'name' => "ping",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Do you have a mic?",
'name' => "mic",
'type' => "select",
'options' => "No,Yes",
'defaultvalue' => "No",
'required' => 1
),
array(
'caption' => "Why do you want to join?",
'name' => "joinreason",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Tell us a bit about yourself",
'name' => "bio",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Any other comments?",
'name' => "comments",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Did a member invite you?",
'name' => "invite",
'type' => "radio",
'options' => "Yes,No",
'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=13;
//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 = 'Application';
$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 = 'Forum post autogenerated by application form on behalf of ' . $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 .= '[list][b]' . $field['caption'] . '[/b][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' => 0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// 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>';
}
}
Remove the extra 'list' from your code :
Change...
$postbody .= '[list][b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
To this :
$postbody .= '[list][b]' . $field['caption'] . '[/b][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
And see if that works.
Thanks Freddy, didn't notice that. Unfortunately it didn't work though :(
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg25.imageshack.us%2Fimg25%2F5813%2Ftestqm.png&hash=b64763b79233f2b7c3e31c7e8cb90ccae3557069)
Like I said, if I hit modify, and don't change anything, it will be normal, but I'd rather it just work when someone applies. :)
What are your SMF and TP versions Mr Bloodlvust ?
Freddy, I'm rocking SMF 2.0 RC4 and TP 1.0 RC1
OK yeah, I am getting the same results here. Leave it with me a while.
See if this works, it seems okay here. After taking a proper look, it was the way 'list' was getting used. I should have suggested removing the first one, not the second doh !
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 have an account on our site before you can apply.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "So you've decided you want to join The Angels Of Armageddon. Great! Just keep the following in mind when applying:<br><br><b>1.</b> Be involved in the forums and be active on the server as much as possible. This shows us that you're an active part of the community and are serious about joining, and will help your application more than you might think!<br><b>2.</b> Having a mic is a requirement to join. We may be willing to make exceptions for extreme cases, and you can make your case in the comments of your app.<br><br><b>Approval Process</b>:<br>Upon posting your application, a forum post will be made in the Applications Section of the board. In your post, anyone may comment and/or vote, though we will only count votes from members, and if we look for input outside of the clan, only our regulars will be taken into consideration. It's best to have been playign with us long enough that we know who you are, it's hard to want you to join us if we don't know you.<br><br>Once your application has been received, you must garner a 'yes' vote from at least 60% of the Joint Chiefs Of Staff. At that point your status as a member will be either accepted or rejected by Bloodlvst (very rarely will you actually be rejected), and you will officially be a member and be given tags. You may not wear tags until all of this has occured. <br>";
$thanks_text = "Thanks for applying! You can check out the progress of your application in the Applications Section.";
// 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 On Server",
'name' => "nickname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Real Name",
'name' => "realname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Location",
'name' => "location",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Age",
'name' => "age",
'type' => "select",
'options' => "13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40+",
'defaultvalue' => "16",
'required' => 1
),
array(
'caption' => "Ping On Server",
'name' => "ping",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Do you have a mic?",
'name' => "mic",
'type' => "select",
'options' => "No,Yes",
'defaultvalue' => "No",
'required' => 1
),
array(
'caption' => "Why do you want to join?",
'name' => "joinreason",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Tell us a bit about yourself",
'name' => "bio",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Any other comments?",
'name' => "comments",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Did a member invite you?",
'name' => "invite",
'type' => "radio",
'options' => "Yes,No",
'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=13;
//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 = 'Application';
$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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
$fieldCounter = 0;
foreach ($fielddef as $field) {
$fieldCounter++;
// 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 .= $fieldCounter . '. [b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' => 0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// 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>';
}
}
Thanks a ton Freddy! Works perfectly!
You da man! :D
Thanks Freddy for the assistance. I do have an issue though. When I submit the form, the Thank you page does not show as well as the board I chose does not get a post of the form in it.
Using;
Powered by SMF 2.0 RC5 | SMF © 2006â€"2011, Simple Machines LLC
TinyPortal 1.0 RC1 | © 2005-2010 BlocWeb
XHTML
RSS
WAP2
Day Relax by Skinmod
And here is the code;
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 registered on our site before you can sign up for Horse Camp.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "So you've decided you would like to attend Six Star Stables Horse Camp this summer. That is Great News! Just keep the following in mind when signing up:<br><br>
<b>1.</b> You will be required to HAVE A GREAT WEEK and be prepared to learn about horses. <br/><br/>
<b>2.</b>We will have barn projects that all the kids will participate in. <br><br>
We work this camp around the campers need to not only learn about a Horse Farm but also discipline, confidence, focus and FUN!<br> Please fill out all the fields in the Sign Up Form below. This way we will be able to get a good idea of who you are prior to meeting you for the first time.<br><br> ";
$thanks_text = "Thanks for signing up for Horse Camp! One of our Staff members will be getting in touch with you soon. Also, please check back for NEWS about the barn on the forums.<br><br>
Thank You again. <br>
Six Star Stables Staff";
// 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 On The Website",
'name' => "nickname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Real Name",
'name' => "realname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Location",
'name' => "location",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Age",
'name' => "age",
'type' => "select",
'options' => "6,7,8,9,10,11,12,13,14,15,16+",
'defaultvalue' => "10",
'required' => 1
),
array(
'caption' => "Phone Number",
'name' => "phonenum",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Is phone best means of contact?",
'name' => "phonecont",
'type' => "select",
'options' => "No,Yes",
'defaultvalue' => "Yes",
'required' => 1
),
array(
'caption' => "Why would you like to attend Horse Camp?",
'name' => "joinreason",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Tell us a bit about yourself",
'name' => "bio",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Any other comments?",
'name' => "comments",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Did a Barn Member invite you?",
'name' => "invite",
'type' => "radio",
'options' => "Yes,No",
'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=4.0;
//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 = 'Application';
$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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
$fieldCounter = 0;
foreach ($fielddef as $field) {
$fieldCounter++;
// 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 .= $fieldCounter . '. [b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' => 0 ,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// 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, those with an asterisk are required(*).</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>';
}
}
Thanks for any help.
NCSurfer,
Since I see you on, let's try a couple of things. First of all,
$board_id=4.0;
and
$board_id=4;
and see if that fixes the issue with the topic being posted.
Secondly, your $thanks_text probably needs to be edited so that it's all on one line though I might be able to check this and see what's going on with that.
ZarPrime
I cleaned up the code a little bit. Change everything that I saw to be XHTML compliant and also change the tab/spacing to make it look more like SMF standards. Fixed the $board_id variable for you too. I'm sure that 4.0 makes a difference in the problem you were having as 4.0 is not necessarily an int, but a decimal.
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 registered on our site before you can sign up for Horse Camp.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "So you've decided you would like to attend Six Star Stables Horse Camp this summer.
That is Great News! Just keep the following in mind when signing up:<br /><br />
<b>1.</b> You will be required to HAVE A GREAT WEEK and be prepared to learn about horses. <br/><br/>
<b>2.</b>We will have barn projects that all the kids will participate in. <br /><br />
We work this camp around the campers need to not only learn about a Horse Farm but also discipline, confidence, focus and FUN!<br /> Please fill out all the fields in the Sign Up Form below. This way we will be able to get a good idea of who you are prior to meeting you for the first time.<br /><br /> ";
$thanks_text = "Thanks for signing up for Horse Camp! One of our Staff members will be getting in touch with you soon.
Also, please check back for NEWS about the barn on the forums.<br /><br />Thank You again. <br />Six Star Stables Staff";
// 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 On The Website",
'name' => "nickname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Real Name",
'name' => "realname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Location",
'name' => "location",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Age",
'name' => "age",
'type' => "select",
'options' => "6,7,8,9,10,11,12,13,14,15,16+",
'defaultvalue' => "10",
'required' => 1
),
array(
'caption' => "Phone Number",
'name' => "phonenum",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Is phone best means of contact?",
'name' => "phonecont",
'type' => "select",
'options' => "No,Yes",
'defaultvalue' => "Yes",
'required' => 1
),
array(
'caption' => "Why would you like to attend Horse Camp?",
'name' => "joinreason",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Tell us a bit about yourself",
'name' => "bio",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Any other comments?",
'name' => "comments",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Did a Barn Member invite you?",
'name' => "invite",
'type' => "radio",
'options' => "Yes,No",
'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 = 4; //(single digit only. No decimals)
//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 = 'Application';
$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 = 'Forum post autogenerated by application form on behalf of ' . $context['user']['name'] .'<br /><br />';
$fieldCounter = 0;
foreach ($fielddef as $field) {
$fieldCounter++;
// 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 .= $fieldCounter . '. [b]' . $field['caption'] . '[/b][list][li]' . $_REQUEST[$field['name']] . '[/li][/list]<br />';
}
$msgOptions = array(
'id' => 0,
// Use the one below if poster doesn't enter subject
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['nickname']),
// 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, those with an asterisk are required(*).</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>';
}
}
Great, thanks IchBin.
I just tried out the new code but still do not get the Thank You page or a post in the forums. Double checked all the info but can not seem to make it work. I did not change anything from the code you modified. Any other ideas?
Thanks
I just copy and pasted it into my test site. Enabled email to see if I'd get an email as well. When I submit the form it both sends me an email as well as posts the topic to the board I assigned in the variable. Not sure what your problem is. Check your logs and see if you have any errors or something.
ccf6e5b21196e9b3446427b095065057
Type of error: Undefined
http://www.sxxxxxxxxxs.com/index.php?
8: Undefined index: page
File: /home/sxxxxxxxxs/public_html/Themes/default/languages/Post.english.php (tp_below sub template - eval?)
Line: 228
This is the error that is showing up.
You need to disable template eval. If you are running SMF2 you can do that in the Admin > Configuration > server settings.
Clear the log then try the page again. Post the new error in the log when you get it. You can actually search for the error first, and likely find that it's been fixed.
I turned the evaluation off, but still get this error. Also, I still am not getting the thank you or post in forum when submitting the form.
File: /home/sixstars/public_html/Themes/default/TPsubs.template.php(112) : eval()'d code
Line: 232
You need to post the full error. Which includes the URL. The error you posted is saying that you have an error in either a PHP article or block. If the error you posted is not in relation to the article code you are using here, I'm afraid there won't be anything we can do to help you.
Sorry, this is the error that is showing up.
http://www.sxxxxxxxs dot com/index.php?http://www.sxxxxxxxs dot com/
8: Undefined index: page
File: /home/sixstars/public_html/Themes/default/TPsubs.template.php(112) : eval()'d code
Line: 232
why would it have this line http://www.sxxxxxxxs dot com/index.php?http://www.sxxxxxxxs dot com/ with the domain twice?
My guess is that the error is from one of your blocks. You can disable your custom blocks and then enable them one by one to see which one is throwing the error. But I don't think the error is related to your problem with this code.
We've been using this Form for a while and love it. Have made changes to it using you guru's ideas (bold lettering, colors, etc) so I'm sure this is a problem on my end than the form.
We have recently tried to add a recruiter's address to the form for an email send as well and it won't work. The site does send notifications for PMs and new member joins just fine.
Is this a switch I need to turn on somewhere or something else?
Using SMF 2.0.2 and TP 1.104.
GreenEyed,
Could you please post the code you are using for the form in your next post here using the code tags so that we can take a look at it.
ZarPrime
I went back to our base code, without the frills, to make sure it wasn't an issue there, still won't send an email. Here is that code.
global $sourcedir, $context, $scripturl, $user_info;
// Generic Application Form
// URL: http://www.tinyportal.net/index.php?topic=29670.msg236779#msg236779
// Date: 30 November 2009
// Guests can't fill out the form
if ($context['user']['id'] == 0)
echo 'You must be logged in before you can apply. Please register and try again.';
else {
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');
// CONFIGURATION SECTION
$intro_form = "Think you have what it takes? Fill out this application and a recruiter will email you soon. If a question does not apply, please enter 'NA'.";
$thanks_text = "Thank you for applying with =VX9=. You will be contacted shortly.";
// 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' => "Recruit Application",
'name' => "heading",
'type' => "heading",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Name",
'name' => "realname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Email address",
'name' => "Email",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "In Game Name",
'name' => "Nickname",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "How did you hear about =VX9=?",
'name' => "Marketing",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "What game are you applying for?",
'name' => "Game",
'type' => "select",
'options' => "Battlefield Series, Call of Duty Series, Valve Series, America's Army, Console Division(Xbox 360, etc), Planetside 2, World of Tanks, ",
'defaultvalue' => "Battlefield Series",
'required' => 1
),
array(
'caption' => "Age",
'name' => "age",
'type' => "select",
'options' => "13,14,15,16,17,18,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' => "Sex",
'name' => "sex",
'type' => "radio",
'options' => "M,F",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Location",
'name' => "Location",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Choose your gaming system",
'name' => "system",
'type' => "select",
'options' => "PC, XBox, PS3",
'defaultvalue' => "PC",
'required' => 1
),
array(
'caption' => "Registered with Battlelog?",
'name' => "battlelog",
'type' => "radio",
'options' => "Yes, No",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Battlelog Name",
'name' => "BattlelogName",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Registered with xFire?",
'name' => "xfire",
'type' => "radio",
'options' => "Yes, No",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "xFire Name",
'name' => "xFireName",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Registered with Steam?",
'name' => "Steam",
'type' => "radio",
'options' => "Yes, No",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Steam ID - NOT Steam name!",
'name' => "SteamID",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "XBox Gamertag",
'name' => "Gamertag",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "PS3 Name",
'name' => "PS3Name",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Previous Clan(s)",
'name' => "PreviousClans",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Have you ever been VAC or PB banned?",
'name' => "banning",
'type' => "radio",
'options' => "Yes, No",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "If so, please explain.",
'name' => "Bullshit",
'type' => "text",
'options' => "",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Do you have voice communication ability? (Mic, Headset, Teamspeak)",
'name' => "Teamspeak",
'type' => "radio",
'options' => "Yes, No",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "Would you be willing to donate to help pay for servers?",
'name' => "Donate",
'type' => "radio",
'options' => "Yes, No, Occasionally",
'defaultvalue' => "",
'required' => 0
),
array(
'caption' => "How often do you play?",
'name' => "GamingHabits",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
array(
'caption' => "Why do you want to join =VX9=?",
'name' => "Why",
'type' => "textarea",
'options' => "",
'defaultvalue' => "",
'required' => 1
),
);
//send the application by email?
$enable_email=true;
// email address of recruitment staff member
$email_address='recruitsapp@vx9.com';
//post the application on forum?
$enable_post=true;
//board id to which the application should be posted
$board_id=31;
// Poll options
$add_poll = 0; // 0 = No poll; 1 = add poll
$poll_question = "Accept this member?"; // This is the question for the poll
$expireTime = 0; // Change this to the number of days you want the poll to run
$hideResults = 0; // 0 = Results are always visible; 1 = Can see results only after voting; 2 = Can see results only after poll expires
$changeVote = 0; // 0 = Voters can not change their votes; 1 = Voters can change their votes
$poll_choices = array('Yes','No'); // The options listed for the poll
//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 = 'Application';
$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
if ($add_poll === 1) {
$posterName = $context['user']['name'];
if ($expireTime > 0)
$expireTime = time() + $expireTime * 3600 * 24;
db_query("
INSERT INTO {$db_prefix}polls
(question, hideResults, maxVotes, expireTime, ID_MEMBER, posterName, changeVote)
VALUES ('$question', '$hideResults', '1', '$expireTime', '$ID_MEMBER', '$posterName', '$changeVote')", __FILE__, __LINE__);
$ID_POLL = db_insert_id();
// Create each answer choice.
$i = 0;
$setString = '';
foreach ($poll_choices as $option)
{
$setString .= "
('$ID_POLL', '$i', SUBSTRING('$option', 1, 255)),";
$i++;
}
db_query("
INSERT INTO {$db_prefix}poll_choices
(ID_POLL, ID_CHOICE, label)
VALUES" . substr($setString, 0, -1), __FILE__, __LINE__);
}
else
$ID_POLL = null;
$postbody = 'Recruitment application has been made by ' . $context['user']['name'] .'<br /><br/>';
foreach ($fielddef as $field) {
if ($field['type'] == 'heading')
$postbody .= $field['caption'] . '<br />';
elseif ($field['caption'] == 'Comments')
$postbody .= '[b][color=red]' . $field['caption'] . '[/color][/b]: ' . $_REQUEST[$field['name']] . '<br />';
else
$postbody .= '[b]' . $field['caption'] . '[/b]: ' . $_REQUEST[$field['name']] . '<br />';
}
$msgOptions = array(
'id' => 0 ,
'subject' => '[Pending] Application of ' . addslashes($_REQUEST['Nickname']),
'body' => addslashes($postbody) ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' => array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' => $ID_POLL,
'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 a *.</div>'; }
echo '
<form action="' . $_SERVER['REQUEST_URI'] . '" 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="right">';
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="4" cols="40">';
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>';
}
}
Run the attached file from the root of your SMF forum folder. Make sure you edit the file and change the email on the first line of code to be your own email. Then in your browser go to the file on your site (For example: www.yoursite.com/forum/testMail.php). It should attempt to send 3 different emails to your email. If you do not receive all of them, you may have a host configuration problem with your PHP mail.
If you get all of the emails there is probably a problem in the code.
No go for the test mails. I will dig into the PHPmail issue then.
Thanks much, all!
Okay guys, I have it working now! :D It was an issue on cpanel and we have emails going out. Much obliged, Ich!
woohoo. Glad you got it working.
Okay, next question.
Is it possible with that Form to be able to post to different boards based on the answer to one of the questions?
Hi GreenEyed,
The code is not really designed to do that. It is written so that the application can be saved to a single board.
For instance, from the code you posted, in your "Game" array, you have a choice of 7 selections. I assume that you are wanting to have the application saved to a particular board based on the answer to that question, or maybe it's another array you are talking about. Anyway, this would be problematic and is just not possible with the code as written. Additional coding could possibly be done to allow this but it would take quite a bit of additional code to be able to do that. You'd have to have additional board_id's defined so that additional boards could be specified and then each array would have to have another field added, etc. This is a lot more work than I am willing to get into and would require quite a bit of testing to make sure that it works correctly. If there was a problem with the code as written, I might consider it but the code works well as it is now.
An easier option for something like this would be, as an Admin, to just move the posted applications to the correct boards on a daily basis. Or, you could assign one of your helpers to move the applications to the appropriate board after you give them permission to move topics. Editing this code is just not something that I really care to get into at this point, and I doubt that anyone else would want to get into this either. Sorry. :o
ZarPrime
Yes, I've been moving them manually, which isn't so bad. You answered my main question though, so I know it's possible. I wouldn't expect you fine folks to go into that much work, but this gives me something to do in my spare time as I'm learning this. I keep an updated copy of our site running on my local machine so I can change, screwup, blow up, or fix this without it being live.
As I delve into this I may have more specific questions, but I really appreciate how helpful you all are. It's made me want to learn this if for nothing more than the challenge.
Thank you, Zar and Ich, you two are pretty darn awesome in my book! O0
Link to my forum: http://www. animenewsinc. net/
SMF version: 2.0.4
TP version: 1.107
Default Forum Language: english
Theme name and version: bad company 3
Browser Name and Version: firefox latest version
Mods installed: trying to use the application block
Related Error messages: TPSubs.php(1739) : eval()'d code
Line: 152
when i use the code given i am given this error :
TPSubs.php(1739) : eval()'d code
Line: 152
its when i try to post to a forum that exists. i am not sure how to fix it. i have looked it over and can't seem to find a fix for it. it will work if i use email but i would whether use either post or both. i don't want email really.
The last I remember this code was only for SMF1. Did I miss the update somewhere in this topic?
i gotten it fixed. i found a updated source code for it. thanks for the help