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

Recent

Welcome to TinyPortal. Please login or sign up.

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

[Done!] Join Us! form

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni

So you're wanting some specific captcha thing to be incorporated into the script?

Wouldn't it be easier to just have people register before they fill out the form?

Inny

Quote from: JPDeni on March 02, 2009, 12:22:20 AM
So you're wanting some specific captcha thing to be incorporated into the script?

More specifically i want an anti-bot measure. From what i can think i can go along with the captcha or as said on my latest reply maybe a box that accepts only specific value that can hold a question like "Are you a bot" but you have to put the number 1137 in order to proceed with the application.

Quote from: JPDeni on March 02, 2009, 12:22:20 AM
Wouldn't it be easier to just have people register before they fill out the form?

Much much more easier but because its a Guild Community, forums only serve the people inside the guild along with some outside friends.




In the code i posted Here captcha works. I also fixed the 1st problem, only problem left is that it "breaks" your theme if the key is not entered correctly.

So if that cant be fixed i can use a box as said above that accepts only specific value.


JPDeni

Well, "captcha" can mean a lot of different things. It stands for ""Completely Automated Public Turing test to tell Computers and Humans Apart." So that would mean it's an anti-bot measure. :)

It's easy enough, I guess to put in something like "What's three plus four? (enter a number)" The thing is that it would be the same all the time, which seems to defeat the purpose.

The other day I found one that had several pictures of actors and the question was which one was  "Brad Pitt". Depending on the subject of your forum, you could do something like that.

Or you could have the new people sign up for an account. After they fill out the form and are approved, they would have full member status. Forum posts would only be readable by those with full member status.

Inny

I prefer captcha but because you need to do some more modifications i can forget the idea and go along the ones that you said, like a mathematical box. Im pretty sure the person that is responsible to alter the form can change the the formula aswell :p

But yeah if you look at the code i posted you might find where the problem is and it breaks the layout of the page. Have no clue how to fix it no matter what i tried. On the other hand.... php is not my strong point :P.

Wish it was an html form :(

JPDeni

The reason that it breaks the form is that it is looking for an SMF template sort of page instead of a TP article sort of page and the php article isn't reloaded.

I hate just about more than anything to program in the dark -- to write code without being able to test it out myself -- but I'm going to give you something to try.

Instead of


if (isset($_REQUEST['submitted'])) {  // Handle the form

// Check whether the visual verification code was entered correctly.
if ((empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1) && (empty($_REQUEST['visual_verification_code']) || strtoupper($_REQUEST['visual_verification_code']) !== $_SESSION['visual_verification_code']))
{
$_SESSION['visual_errors'] = isset($_SESSION['visual_errors']) ? $_SESSION['visual_errors'] + 1 : 1;
if ($_SESSION['visual_errors'] > 3 && isset($_SESSION['visual_verification_code']))
unset($_SESSION['visual_verification_code']);

fatal_lang_error('visual_verification_failed', false);
}


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


try


if (isset($_REQUEST['submitted'])) {  // Handle the form
  $errors = array(); //Initialize error array
// Check whether the visual verification code was entered correctly.
if ((empty($modSettings['disable_visual_verification']) || $modSettings['disable_visual_verification'] != 1) && (empty($_REQUEST['visual_verification_code']) || strtoupper($_REQUEST['visual_verification_code']) !== $_SESSION['visual_verification_code']))
{
$_SESSION['visual_errors'] = isset($_SESSION['visual_errors']) ? $_SESSION['visual_errors'] + 1 : 1;
if ($_SESSION['visual_errors'] > 3 && isset($_SESSION['visual_verification_code']))
unset($_SESSION['visual_verification_code']);

$errors[] = 'Visual verification failed';
}


// Check required fields


I don't know if it'll work or not, but it might.

Inny

Yeah it doesnt work because you cant pass the Required field check for a reason even if you fill all the info.  :(

JPDeni

I'm not sure what that means. Are you saying that the fields don't fill back in if you don't pass the verification? Or something else?

You do realize that that the SMF verification doesn't really work, right? If you mess up the verification, the "I agree" button doesn't work right when you go back.

I don't know enough about how they wrote the verification to be able to make any more suggestions about it. The only suggestion I have is to use something other than the SMF verification that I already mentioned.

Inny

Quote from: JPDeni on March 02, 2009, 11:04:25 PM
I'm not sure what that means. Are you saying that the fields don't fill back in if you don't pass the verification? Or something else?

You do realize that that the SMF verification doesn't really work, right? If you mess up the verification, the "I agree" button doesn't work right when you go back.

I don't know enough about how they wrote the verification to be able to make any more suggestions about it. The only suggestion I have is to use something other than the SMF verification that I already mentioned.

No i mean that even if you fill the Required Fields in the form and you press Submit, it always asks to fill the Required Fills even if they were filled before submitting them.

It seems that im gonna go with your suggestions and mathematical boxes :P.

Gonna google for the php code for them, only question if of course i find the correct code: Should i create a new type in:

//       'type' =>         "", // text, radio, select, checkbox, textarea, heading

and then make it appear just every other type?

JPDeni

Actually, I would create a completely separate field and put it just before the submit button.




  echo '
     <TR class ="' . $bg . '"><td>What is five plus seven? (enter a number)</td>
     <td><input type="text" name="mathtest" value=""></td></tr>';
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
    echo '
    <TR class ="' . $bg . '">
      <TD colspan="2" align="center">
  <br>
        <INPUT type="submit" value="Submit">
        <INPUT type="reset" value="Reset"></TD>
    </TR></TABLE></center></form>';


Then, in the place where you're checking, include

    if (!isset(_$REQUEST['mathtest']) or ($_REQUEST['mathtest'] <> 12))
      error[] = 'You didn't get the math problem correct';

Inny

#329

global $sourcedir, $user_info, $context ;

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





// CONFIGURATION SECTION

$intro_form = "<center><h4><font color=red>Even if this is nothing like the normal Applications that you make a post and have to be well written, we still demand that every field that requires a written answer to be well written. </font></h4> </center><br>";   // Can include html

$thanks_text = "<center><h3><font color=red>Thanks for applying. Your application has been submitted successfully. We'll review your application and get back to you.</h3></font></center>"; // what is displayed after the form is submitted

// Define your fields. All of these values need to be defined, even if they are empty.
// The fields will be displayed in the order in which they are listed in the array.
// $fielddef =
//   array(
//     array(
//       'caption' =>      "", // caption to be displayed on the form. Can include symbols and spaces.
//       'name' =>         "", // a unique name for the field. No symbols or spaces
//       'type' =>         "", // text, radio, select, checkbox, textarea, heading
//       'options' =>      "", // for radio and select fields. List in order you wish them to appear, separated by commas; for checkboxes, it's the value to be saved and displayed next to the box
//       'defaultvalue' => "", // the default value for the field. Can be a variable or text. Be sure to enclose text in quotation marks
//       'required' =>     0   // 0 or 1 -- use 1 if the field must be filled out. use 0 if it's optional; never set a checkbox to be required
//     ),
//   );

$fielddef =
  array(
    array(
      'caption' =>      "Email",
      'name' =>         "charemail",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
  ),
    array(
      'caption' =>      "Character Info",
      'name' =>         "heading1",
      'type' =>         "heading",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
array(
      'caption' =>      "Character Name",
      'name' =>         "charname",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Lever",
      'name' =>         "charlevel",
      'type' =>         "select",
      'options' =>      "70,71,72,73,74,75,76,77,78,79,80",
      'defaultvalue' => "80",
      'required' =>     1
    ),
    array(
      'caption' =>      "Race",
      'name' =>         "charrace",
      'type' =>         "select",
      'options' =>      "Orc,Undead,Troll,Tauren,Blood Elf",
      'defaultvalue' => "Orc",
      'required' =>     1
    ),
array(
      'caption' =>      "Class",
      'name' =>         "charclass",
      'type' =>         "select",
      'options' =>      "Druid,Hunter,Mage,Paladin,Priest,Rogue,Shaman,Warlock,Warrior,Death Knight",
      'defaultvalue' => "Druid",
      'required' =>     1
    ),
array(
      'caption' =>      "Days played",
      'name' =>         "charplayed",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
array(
      'caption' =>      "Profession 1",
      'name' =>         "prof1",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
array(
      'caption' =>      "Profession 2",
      'name' =>         "prof2",
      'type' =>         "select",
      'options' =>      "None,Herbalism,Mining,Skinning,Alchemy,Blacksmithing,Enchanting,Engineering,Leatherworking,Tailoring,Jewelcrafting,Inscription",
      'defaultvalue' => "None",
      'required' =>     1
    ),
   array(
      'caption' =>      "How are you speced?",
      'name' =>         "charspec",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Why you speced this way",
      'name' =>         "specinfo",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "What are you class important stats and why",
      'name' =>         "specstats",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
);



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

// email address of recruitment staff member
$email_address='grkronos@gmail.com';

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

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


//END OF CONFIGURATION SECTION



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

      if (!isset(_$REQUEST['mathtest']) or ($_REQUEST['mathtest'] <> 12))
      error[] = 'You didn't get the math problem correct';

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

  foreach ($fielddef as $field)
    if (empty($_REQUEST[$field['name']]) && ($field['required'] == 1)){ $errors[] = $field['name']; }



// There's at least one field missing
  if (isset($errors[0])) {
    foreach ($_REQUEST as $key => $value)
      $fieldvalue[$key] = $value;
  }
  else { // all is well
 
    $show_form='false';
    if ($enable_email) {  // email an application
  $subject = 'Enrollment Application';
  $body = 'Enrollment application has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . '
              ';
      foreach ($fielddef as $field) {
        $body .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '
        ';
      }
      mail($email_address, $subject, $body,"From: " . $user_info['email']);
    }

    if ($enable_post) {  //create new forum post with application

      $postbody = 'Enrollment application has been made by ' . $context['user']['name'] .'<br /><br/>';
  foreach ($fielddef as $field) {
        if ($field['type'] == 'heading')
          $postbody .= '[color=red][u][b]' . $field['caption'] . '[/b][/u][/color]  ' . $_REQUEST[$field['name']] . '<br />';
        else
          $postbody .= '[color=green]' . $field['caption'] . '[/color]  ' . $_REQUEST[$field['name']] . '<br />';
      }
      $postbody .= '';

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

    echo $thanks_text;
  }
}

// Looks like you want the form,
if ($show_form == 'true') {
  echo $intro_form . "<br>";
  if (isset($errors[0])) { echo '<div style="color: red;">Please fill in all fields with a *.</div>';  }
  echo '<form action="' . $scripturl . '?page='  . $_GET['page'] . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
        <center><table width="50%">';
  $bg = 'windowbg2';
  foreach ($fielddef as $field) {
    if ($field['type'] == 'text') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><INPUT id="' . $field['name'] . '" name="' . $field['name'] . '" type="text" value ="' . $fieldvalue[$field['name']] . '" /></TD>
            </TR>';
    }
    elseif ($field['type'] == 'radio') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left">';
              $options = explode(',',$field['options']);
              foreach ($options as $option) {
                echo '<INPUT TYPE="RADIO" NAME="' . $field['name'] . '" VALUE="'. $option . '"';
                if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' CHECKED'; }
                echo '>' . $option . ' ';
              }
              echo '</TD>
            </TR>';   
    }
    elseif ($field['type'] == 'checkbox') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              echo $field['caption'] . ':</TD>
              <TD align="left">';
                echo '<INPUT TYPE="CHECKBOX" NAME="' . $field['name'] . '" VALUE="'. $field['options'] . '"';
                if (isset($fieldvalue[$field['name']]) && ($fieldvalue[$field['name']]==$field['options'])) { echo ' CHECKED'; }
                echo '>' . $field['options'] . '
            </TR>';   
    }
    elseif ($field['type'] == 'select') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '* '; }
              echo $field['caption'] . ':</TD>
              <TD align="left"><SELECT id="' . $field['name'] . '" name="' . $field['name'] . '" style="WIDTH: 152px" value ="';
              echo '" />';
              $options = explode(',',$field['options']);
              foreach ($options as $option) {
                echo '<OPTION value="' . $option . '"';
                if ((isset($fieldvalue[$field['name']])) && ($option == $fieldvalue[$field['name']])) { echo ' selected'; }
                echo '>' . $option . '</OPTION>';
            }
            echo '</SELECT></TD>
            </TR>';
    }
    elseif ($field['type'] == 'textarea') {
      echo '<TR class ="' . $bg . '">
            <TD width = "200px" align="right">';
            if ($field['required'] == 1) { echo '* '; }
            echo $field['caption'] . ':</TD>
            <TD align="left"><TEXTAREA id="' . $field['name'] . '" name="' . $field['name'] . '" rows="4" cols="40">';
            echo $fieldvalue[$field['name']];
            echo '</' . 'TEXTAREA></TD>
  </TR>';
    }
  elseif ($field['type'] == 'heading') {
      echo '<tr><TD colspan="2"><center><table cellSpacing="1" cellPadding="1" width="50%"><TR>
            <font size="8"><TD style="text-align: center; text-decoration: underline;"><font size="4">' .
            $field['caption'] .
            '</font></TD></TR></table></center></td></tr>';
    }
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
  }

    echo '
     <TR class ="' . $bg . '"><td>What is five plus seven? (enter a number)</td>
     <td><input type="text" name="mathtest" value=""></td></tr>';
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
    echo '
    <TR class ="' . $bg . '">
      <TD colspan="2" align="center">
  <br>
        <INPUT type="submit" value="Submit">
        <INPUT type="reset" value="Reset"></TD>
    </TR></TABLE></center></form>';
}


Gives syntax error in:

  if (!isset(_$REQUEST['mathtest']) or ($_REQUEST['mathtest'] <> 12))
      error[] = 'You didn't get the math problem correct';

This website is proudly hosted on Crocweb Cloud Website Hosting.