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: 429
  • Total: 429

[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.

mebymyself

Quote from: J.A.Cortina on October 22, 2006, 11:49:09 PM
Frankly, your request wasn't something that could be answered as it lacked a lot of the definition necessary.

Actually I have no hope that somebody should take this as a SOW and start developing ready-to-use module tailored to my request. Hense I posted some general reqs only.
But just in case if somebody need more specific requirements here they are:
- The form must be used by registred members only (guests cannot access this form)
- Form should consist of several input boxes, check marks  and selection fields. actual fields will be provided if needed but some generic mechanism to post everything on the form is highly desired
- The form should have some simple validation (required fields, "I Agree" checkbox, valid email etc.)
- When form submitted - regular new thread should be created in specific board. The data that user provided should be postet like table or just as fieldname - value pairs.
- As I said it should be regular thread - all rules of the board applied to this post
--------------
I think  it pretty simple - I just don't know database structure good enough to do it by myself. I don't know PHP either - but i got a good book - and hopefully I can modify darthmactis' code to serve all my needs if somebody will give me a push in right direction

BTW darthmactis, I tried your code as is and it do work (mean send an email). now all I need it to creat new topic in the forum...

jacortina

Well, if it's working within the SMF 'rules' for posting (given that you build the message from your form-supplied values), then it's really only a matter of calling the same subroutine that SMF uses to post a new topic. That's the createPost function in Sources/Subs-Post.php (and see the Post2 function in Sources/Post.php to backtrack the construction of the arrays which feed into createPost).

You don't mess directly with the database and a number of default values are supplied.

darthmactis

Quote from: mebymyself on October 23, 2006, 12:51:03 AMBTW darthmactis, I tried your code as is and it do work (mean send an email). now all I need it to creat new topic in the forum...

If i could figure out how to do that i would have LOLLOL

mebymyself

Ok,  I went pretty far (i think)

I created the form
able to sent results to email
and figured out what I need to  create a post

But here is showstoper ... when I call to createPost function located in Subs-Post.php I got an error message:

Fatal error: Call to undefined function createPost() in /home/wowaao/public_html/enroll.php on line 102

Definetly I missing something due to my poor knowladge of PHP.
Somebody can help me fix it, please?

The code of  enroll.php is following:



<?php 

global $sourcedir$user_info$context$enroll_errors;

define('SMF'1);
include(
$sourcedir 'Subs-Post.php');

$email_address='recruitment@wow-aao.net';

$board_id=16;
$thank_you_article_id '20';
$enroll_error_article_id '21';

$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 a name
if (empty($_POST['aa_name']) ){
$enroll_errors[] = 'You forgot to enter your In-Game Nickname.';
}       
// Check for a name
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 ' $REMOTE_ADDR '\n 
    Real Name:  ' 
$_POST['real_name'] . '\n
Email address:  ' 
$_POST['email'] . '\n
Current Game Name:  ' 
$_POST['aa_name'] . '\n
Age:  ' 
$_POST['age'] . '\n
Gender: ' 
$_POST['gender'] . '\n
Location:  ' 
$_POST['location'] . '\n
Current Honor:  ' 
$_POST['honor'] . '\n
Previous clan(s):  ' 
$_POST['prev_clans'] . '\n
Banned from any sever:  ' 
$_POST['banned'] . '\n
Registered with AAOTracker? ' 
$_POST['aaotracker'] . '\n
AAOTracker name:  ' 
$_POST['aaotraker_name'] . '\n
Registred with X-fire?  ' 
$_POST['xfire'] . '\n
X-Fire Account:  ' 
$_POST['xfire_name'] . '\n
TeamSpeak installed?:  ' 
$_POST['ts'] . '\n
Have microphone/headset:  ' 
$_POST['mic'] . '\n
Would like to help pay for a server?: ' 
$_POST['pay'] . '\n  
Why do you want to join -WoW-?  ' 
$_POST['why'] . '\n
Gaming habbits:   ' 
$_POST['habbits'] . '\n
Other information:  ' 
$_POST['other'] . '\n' ;

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

//TODO: create new forum post with application

//smf_makePost($context['user']['id'], $context['user']['name'], $_POST['email'], $subject, $body, $icon, $board_id);
// Create a post, either as new topic (ID_TOPIC = 0) or in an existing one.
    // The input parameters of this function assume:
    // - Strings have been escaped.
    // - Integers have been cast to integer.
    // - Mandatory parameters are set.

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

// Redirect to thank you page
//header("Location: http://$_SERVER['HTTP_HOST']/index.php?page=$thank_you_article_id");
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 );
}
} else { 
// Display the form 

?>





<form action="enroll.php" 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 ="<?php if (isset($_POST['real_name'])) echo $_POST['real_name']; ?>" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">* Email address:</TD>
<TD><INPUT id="email" name="email" type="text" value ="<?php if (isset($_POST['email'])) echo $_POST['email']; else echo $user_info['email'];  ?>" /></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 ="<?php if (isset($_POST['aa_name'])) echo $_POST['aa_name']; ?>" /></TD>
</TR>

<TR class ="windowbg2">
<TD width = "200px">* Age:</TD>
<TD><INPUT id="age" name="age" type="text" value ="<?php if (isset($_POST['age'])) echo $_POST['age']; ?>" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Gender:
</TD>
<TD><SELECT id = "gender" name = "gender" style="WIDTH: 152px" value ="<?php if (isset($_POST['gender'])) echo $_POST['gender']; ?>" />
<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 ="<?php if (isset($_POST['location'])) echo $_POST['location']; ?>" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Current Honor:</TD>
<TD><INPUT id="honor" name="honor" type="text" value ="<?php if (isset($_POST['honor'])) echo $_POST['honor']; ?>" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Previous clan(s):</TD>
<TD><TEXTAREA id="prev_clans" name="prev_clans" rows="4" cols="40" value ="<?php if (isset($_POST['prev_clans'])) echo $_POST['prev_clans']; ?>" ></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 ="<?php if (isset($_POST['banned'])) echo $_POST['banned']; ?>" ></TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Registered with AAOTracker?</TD>
<TD><SELECT id="aaotraker" name="aaotraker" style="WIDTH: 160px" value ="<?php if (isset($_POST['aaotraker'])) echo $_POST['aaotraker']; ?>" />
<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="aaotraker_name" name="aaotraker_name" type="text" value ="<?php if (isset($_POST['aaotraker_name'])) echo $_POST['aaotraker_name']; ?>" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Registred with X-fire?</TD>
<TD><SELECT id="xfire" name="xfire" style="WIDTH: 160px" value ="<?php if (isset($_POST['xfire'])) echo $_POST['xfire']; ?>" />
<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 ="<?php if (isset($_POST['xfire_name'])) echo $_POST['xfire_name']; ?>" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Do you have TeamSpeak installed?:</TD>
<TD><SELECT id="ts" name="ts" style="WIDTH: 160px" value ="<?php if (isset($_POST['ts'])) echo $_POST['ts']; ?>" />
<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 ="<?php if (isset($_POST['mic'])) echo $_POST['mic']; ?>" />
<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 ="<?php if (isset($_POST['pay'])) echo $_POST['pay']; ?>" />
<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 ="<?php if (isset($_POST['why'])) echo $_POST['why']; ?>" ></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 ="<?php if (isset($_POST['habbits'])) echo $_POST['habbits']; ?>" ></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 ="<?php if (isset($_POST['other'])) echo $_POST['other']; ?>" ></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>


<?php
// Close the main IF_ELSE.
?>





jacortina

Try to change:
include($sourcedir . 'Subs-Post.php');

To:
include($sourcedir . '/Subs-Post.php');

mebymyself


mebymyself

Ok here update ...

when I replaced :
   include($sourcedir . 'Subs-Post.php');

with hardcoded :
require_once( '/home/wowaao/public_html/Sources/Subs-Post.php');

I got different error:
Fatal error: Call to undefined function db_query() in /home/wowaao/public_html/Sources/Subs-Post.php on
line 1559

any idea what else to include?

akulion

include($one_cup_of_coffee and patience);

that may work :2funny:

mebymyself

Sure?

I included already lot of coffee and even more patiece ...
But i am serious now...

JPDeni

db_query is in Subs.php

If this is in a TPBlock, you should be able to just use

require_once('Subs.php');
require_once('Subs-Post.php');

The code in the blocks is evaluated from within Load.php, which is in the same directory as the other .php files, so you don't need to put in the directory. Or you can put in the full directory, as you found out. :)

This website is proudly hosted on Crocweb Cloud Website Hosting.