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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 11:18:47 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 115
  • Total: 115

[Done!] Join Us! form

Started by mebymyself, October 19, 2006, 08:10:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

Sure. :)

<TD><INPUT id="real_name" name="real_name" type="text" value ="';
if (isset($_POST['real_name'])) echo $_POST['real_name'];
echo '" /></TD>

mebymyself

#31
Hooah!  Thank you all who helped me! It's working!!!

Here how to do "Join Us" recruitment form that upon submittion sends email to the specified address and also create new topic in the specified Board

1. Create PHP article to be redirected to when the form is succesfully submited. Let's call it "Thank You" article
it can be something like this:



global $user_info;
echo "
<h3>Thank you for applying, " . $user_info['name'] . "! </h3><br />
<p>Your application has been sent to our reqruitment officers by email and also new topic has been created on your behave in  Reqruitment Department's forum. <br/>
Our decision will be posted here. You also will recieve an email when the decision will be done.<br/>
Please feel free to add any information you want to share with us.<br/>
<br /></p>";




2. Then create PHP article like this:





global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

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

// email address of reqruitment staf member
$email_address='recruitement@your-clan.com';

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

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

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

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


//END OF CONFIGURATION SECTION

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

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

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


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



// email an application

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

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



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



//create new forum post with application

$msgOptions = array(
'id' =>  0 ,
'subject' => '[Pending] Application of ' . $context['user']['name'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);
   
if ($enable_post)
            createPost($msgOptions, $topicOptions, $posterOptions);

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

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

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



}
}
//else { // Display the form

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

';




3. In configuration section of the code change the variables with actual values

4. you can modify the look and feel of the form, the post and the email text if you want

That's it ...

I am not PHP expert but if you have problems post here - and I'll try to help .

If you have some suggestions or additions - post it :)

Assistance

//the id of the this article
$this_article_id '19';

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


what if i used a custom action

action=join
???

mebymyself

I don't know how to do it with custom actions.
I believe it will require external php file or modification of template.

All my attempts with external file failed :(  as you can see from this thread

Assistance

umm kinda, i have the custom action mod, so it would simply be copy paste, pretty much the same code.  I'm sure I could be fine with it, just prefer actions so when viewing online list i can that people are joining.


mebymyself

Quote from: londonhogfan on November 03, 2006, 05:26:25 AM
http://www.tinyportal.net/smf/index.php?topic=4560.msg40861#msg40861

works pretty good on my site.
http://www.the-rota.com/index.php?page=24 (at the bottom)

OMG!!!  Where you were before!!! :-\
I reinvented the wheel and did it in bad manner :uglystupid2: :idiot2:

Ok anyway it was my first attempt to do something like this ::)
Thank you for your input

mebymyself

londonhogfan,
Now i see that my code is somehow more useful because i have full control on the process
I noticed on your site it says:
QuoteOnce submitted, it will take you to a pre-formatted post on the member applications board, where you will still need to hit the post button.

My code is totally automated. And also i want to expand it to
1. Do not allow clan members fill the form (obvious but you know as soon as I informed that the form is ready I recieved 3 apps from exicting members :)   ... testing ...)

2. Do not allow double applications. instead it should take to existing post and suggest modify it

3. Create another post in members only forum with poll. This will allow Clan members disscuss pending application and vote.
 

akulion

Thanks everyone for the great code :up:

mebymyself