Passing form data into an SMF forum

Started by Boworr, February 27, 2006, 05:14:31 PM

Previous topic - Next topic

Boworr

Hi,

We use SMF for our World of Warcraft guild and I'd like some advice on how we can improve our new members nomination process. Currently we ask people to post into a forum thread, but I'd like to make it slicker by getting them to complete a form that would then 'post' the details into a private thread for the guilds leaders to read.

For example. On my form I might have simple fields for Character Name, Class, Level and maybe a reason for wanting to join. They would be able to select some of these options from drop down lists and then hit submit. The entry would then appear in a forum as pre-formatted text, like this

Character Name: Merlin
Character Class: Mage
Level              : 60
Reason to join  : My friend recommended this guild

I can create the form, no problem but how would I get the data into and SMF forum or thread?

oxynom

The easy way ( doing it external without messing with the smf code)

1. Create the form with the information you want to have inserted.


...
<form action="nomination.php" method="POST">
Character Name: <input type="text" name="char_name" /><br />
Character Class: <input type="text" name="char_class" /><br />
Level: <input type="text" name="char_level" /><br />
Reason to join: <input type="text" name="char_reason" /><br />
<input type="submit" name="nomination"  />
</form>
...


2. Gather the values and create the message

<?php
if (isset($_POST['nomination'])) {

foreach ($_POST as $key => $var) {
$$key $var;
}

$new_nomination "
Character Name: "
.$char_name."<br />
Character Class: "
.$char_class."<br />
Level: "
.$char_level."<br />
Reason to join: "
.$char_reason."<br />";

}
?>



3. Get the values into the database

Easiest would be if you already have a topic open for these entries. Then you can get the topic number and insert the a new messege into {$db_prefix}messages. Other wise you would have to create a new topic in {$db_prefix}topics.

For the MySQL Syntax you insert $new_nomination into the body colum. The other variables you need to get either from the forum or from SSI.php

{$db_prefix}messages
(ID_BOARD, ID_TOPIC, ID_MEMBER, subject, body, posterName, posterEmail, posterTime,posterIP, smileysEnabled, modifiedName, icon)

Take a look at "function createPost(&$msgOptions, &$topicOptions, &$posterOptions)" in Sources/Subs-Post.php.
If you are a little interested in Travel then visit my Project.
SMF 1.1 RC2 bridged with Coppermine and heavily modded.
Destinedia - The Shrine of Travel [nofollow]

kangkenyot

where i must "Create Form" and "Gather the values and create the message" ? in existing php or create new one?

would you like to advise me step by step?

sorry for my dummy question.

Boworr

Hey thanks a lot for taking the time to post this.. I'll give it a try later :)

kangkenyot


Holyfrey

Is it anyone that have got this to work ?

And is it posible you can post your files or work, wil be cool to have had this on my smf site to.

Advertisement: