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

Generic Application Form

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

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 />';
}

Dramber

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!

JPDeni

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.

Dramber

That did it! Thanks a bunch. I knew it was something simple. :P


JPDeni

I just forgot about it. I'm glad you mentioned it. Off to fix the original code.

Thank you!

Dramber

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.

wilsy

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.

JPDeni

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.

Zetan

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.

wilsy

Thanks JP and Zetan, really appreciated. I might add another level of membership based off guests and reopen registration which should do the trick ;)

This website is proudly hosted on Crocweb Cloud Website Hosting.