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

Recent

Welcome to TinyPortal. Please login or sign up.

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

[Done!] Join Us! form

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Inny

Is there any chance to get with an easy way the option to upload files as attachment within a field?

JPDeni

Shaktii, try this. Instead of


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


use


// print out thank you
echo "
<h3>Thank you for applying, " . $user_info['name'] . "! </h3><br />
<p>Your application has been sent to our recruitment officers by email and also new topic has been created on your behave in  Recruitment Department's forum. <br/>
Our decision will be posted here. You also will receive 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>";


It occurred to me that the next time the database was being accessed was in printing out that page. Maybe that's where your database problems are located.

Inny, not an easy way, no. :) There are a number of things that would have to be changed, resulting in, pretty much, a completely new script.

darrenelkins

JPDeni,

I have now got another solution working perfectly, seems to be very similar to the code used in the one that gave me the error.

Thanks for your assistance all the same :)

JPDeni

I'm so glad you got it working. The final result is all that matters.

durgia

ok... ran into another issue.... is it at all possible to make the "thank you text" contain html (or other format commands) that will not appear in email.

Currently I have some html in my Thank you page and that thank you page is emailed to the "recruitment" member and the person registering with the registration info. When the thank you text is added to the email it shows all code (line breaks, centering etc)

(for the code I am using look back a few posts)


all it really needs to do is center the info and put in some line breaks within the displayed thank you page, but not show the code for it on the emailed thank you page.

JPDeni

Just put the html in the variable. You might need to play around with the quotation marks a bit, but since I don't know exactly what you want, I can't tell you for sure.


$thanks_text = '<div style="text-align:center">Thank you for registering.</div>';; // what is displayed after the form is submitted


Toss in line breaks as needed.

durgia

this is the thank you text:


$thanks_text = " Thank you for registering. This message confirms that you have successfully sent your registration information to the Executive. Until this information has been verified and your payment has been received we cannot guarantee availability. Please forward payment by Cheque or Money Order made out to: aaaaa to the address listed below:

<center><br /><br />aaaa
<br />cbbbbb
<br />cccccccc
<br />ddddddddddddd
<br />1111111111
<br /><br /></center>Your Registration Information is listed below. A copy of this information has been emailed to you for future reference. <br /><br /> ";


the email looks like this:

Registration has been made by  from IP Address 1111111 Thank you for registering. This message confirms that you have successfully sent your registration information to the Executive. Until this information has been verified and your payment has been received we cannot guarantee availability. Please forward payment by Cheque or Money Order made out to: aaaaaaa to the address listed below:

<center><br /><br />aaaa
<br />cbbbbb
<br />cccccccc
<br />ddddddddddddd
<br />1111111111
<br /><br /></center>Your Registration Information is listed below. A copy of this information has been emailed to you for future reference. <br /><br />
              First Name: Final
        Last Name: Test
       Email Address: email@email.com
       Mailing Address: 111
       City: Somewhere
       Province: aaaaa
       Postal Code: aabbaabb
       Preferred Date: May 12
       Cost:    Member ($200)
       Company: hmmm
       Contact Phone Number (optional): 1234567890
       Additional Information (optional): This is a test


so.... ideas are welcome

JPDeni

Then you have changed the code to include the $thanks_text variable into the email, which was not what was in the code you posted before.

If you want me to figure out how to make it work for you, you'll have to repost your code.

durgia

I don't remember changing it after that, sorry about that!!

global $sourcedir, $user_info, $context ;

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



// CONFIGURATION SECTION

$intro_form = "Please use this online registration form to enroll in the .";   // Can include html

$thanks_text = " Thank you for registering. This message confirms that you have successfully sent your registration information to the Executive. Until this information has been verified and your payment has been received we cannot guarantee availability. Please forward payment by Cheque or Money Order made out to: lalalalalla to the address listed below:

<center><br /><br />lalalalala
<br />abc 123l
<br />123 4567
<br />aaaa, sssssn
<br />aaaaa
<br /><br /></center>Your Registration Information is listed below. A copy of this information has been emailed to you for future reference. <br /><br /> "; // 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' =>      " First Name",
      'name' =>         "fname",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
    array(
      'caption' =>      " Last Name",
      'name' =>         "lname",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
    ),
    array(
      'caption' =>      "Email Address",
      'name' =>         "email",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
    ),
    array(
      'caption' =>      "Mailing Address",
      'name' =>         "address",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1   
),
    array(
      'caption' =>      "City",
      'name' =>         "city",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
),
    array(
      'caption' =>      "Province",
      'name' =>         "province",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
),
    array(
      'caption' =>      "Postal Code",
      'name' =>         "postal",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     1
),
    array(
      'caption' =>      "Preferred Date",
      'name' =>         "date",
      'type' =>         "select",
      'options' =>      "May 12,May 13",
      'defaultvalue' => "",
      'required' =>     1
    ),
array(
      'caption' =>      "Cost: Register by March 31 and Save $50!",
      'name' =>         "member",
      'type' =>         "radio",
      'options' =>      " Member ($250),Non-Member ($300), Early Bird:  Member ($200), Early Bird Non-Member ($250)",
      'defaultvalue' => "",
      'required' =>     1
    ), 
    array(
      'caption' =>      "Company",
      'name' =>         "company",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Contact Phone Number (optional)",
      'name' =>         "phone",
      'type' =>         "text",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
    array(
      'caption' =>      "Additional Information (optional)",
      'name' =>         "info",
      'type' =>         "textarea",
      'options' =>      "",
      'defaultvalue' => "",
      'required' =>     0
    ),
);


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

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

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

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


//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 = 'Registration: ';
  $body = 'Registration has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . $thanks_text . '
              ';
      foreach ($fielddef as $field) {
        $body .= $field['caption'] . ': ' . $_REQUEST[$field['name']] . '
        ';
      }
      mail($email_address, $subject, $body,"From: " . $_REQUEST['email']);
mail($_REQUEST['email'], $subject, $body,"From: " . $email_address);
    }

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

      $postbody = 'Enrollment application has been made by ' . $context['user']['name'] .'<br />
                   <table>';
      foreach ($fielddef as $field) {
        $postbody .= '<tr><td>' . $field['caption'] . '<td></td><td>  ' . $_REQUEST[$field['name']] . '</td></tr>';
      }
      $postbody .= '</table>';

      $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;
echo '<table border="1">';
foreach ($fielddef as $field) {
        echo '<tr><td>' . $field['caption'] . '</td><td>  ' . $_REQUEST[$field['name']] . '</td></tr>'; }
echo '</table>';
  }
}

// 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="100%">';
  $bg = 'windowbg2';
  foreach ($fielddef as $field) {
    if ($field['type'] == 'text') {
      echo '<TR class ="' . $bg . '">
              <TD width = "200px" align="right">';
              if ($field['required'] == 1) { echo '<div style="color: red;">*</div> '; }
              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 '<div style="color: red;">*</div> '; }
              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 '<div style="color: red;">*</div> '; }
              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 '<div style="color: red;">*</div> '; }
            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 class ="' . $bg . '">
            <TD colspan="2">' .
            $field['caption'] .
            '</TD></TR>';
    }
    if ($bg == 'windowbg2') { $bg = 'windowbg'; }
    else { $bg = 'windowbg2'; }
  }
  echo '
    <TR class ="' . $bg . '">
      <TD colspan="2" align="center">
        <INPUT type="submit" value="Submit">
        <INPUT type="reset" value="Reset"></TD>
    </TR></TABLE></center></form>';
}

JPDeni

You'll need to have two different "thanks" messages.

After the current $thanks_text line, add


$thanks_email = 'Thanks'; // This is part of the email message


Change


    if ($enable_email) {  // email an application
  $subject = 'Registration: ';
  $body = 'Registration has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . $thanks_text . '
              ';


to


    if ($enable_email) {  // email an application
  $subject = 'Registration: ';
  $body = 'Registration has been made by ' . $context['user']['name'] .
          ' from IP Address ' . $user_info['ip'] . $thanks_email . '
              ';

This website is proudly hosted on Crocweb Cloud Website Hosting.