You are invited to Log in or Register a free Frihost Account!

Application form - getting rid of ucwords

Heya I am managing world of warcraft guildsite on PHP-Fusion, and on PHP-Fusion forums I got nice application form:


| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| Filename: application.php
| Author: Starefossen
| Form is made on request by Starefossen.
| No warranty is given, please visit the PHP-Fusion
| MODs & Infusions site for help :)
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
require_once "maincore.php";
require_once THEMES."templates/header.php";

if (!iMEMBER) { redirect(BASEDIR."index.php"); }

|                APPLICATION SETTINGS             |
$form_settings['name']            = "Application Form";   // This will be the name of the Application Form
$form_settings['desc']            = "Do not push ENTER while filling this application. It will make your application submitted!";

$form_settings['subject_key']      = "form_character_name_spec_class";         // This will be the form input which is used as subject.
$form_settings['subject_prefix']    = "Application: ";    // This will come right before the subject. Set this to blank if not needed.
$form_settings['forum_id']          = "7";               // This will be the forum the thread is posted in.

|                APPLICATION FORM                |
   EG: <input type='text' class='textbox' name='form_name' style='width:250px;' />
function application_form($country_opts) {
   global $form_settings;
   // Start Form
   echo "<form action='".FUSION_SELF."' method='post'>";
   echo "<table class='tbl-border' width='100%'>\n<tr>\n";
   echo "<td class='tbl1' colspan='2'>".$form_settings['desc']."</td>\n";
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>A. Basic Information </strong></td>\n";
   // Name Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Name: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_name' style='width:370px;' /></td>\n";
   // Age Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Age: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_age' style='width:370px;' /></td>\n";
   // Gender Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Gender: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_gender' style='width:370px;' /></td>\n";
   // Country Input
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Country: </td>\n";
      echo "<td class='tbl1'><select class='textbox' name='form_country' style='width:370px;'>$country_opts</select></td>\n";
   // Occupation
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Occupation: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_occupation' style='width:370px;' /></td>\n";
   // Yourself
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Tell us a little bit about yourself: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_tell_us_a_little_bit_about_yourself' style='width:370px;' /></td>\n";
   // Playtime
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>How long have you played WoW? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_how_long_have_you_played_wow' style='width:370px;' /></td>\n";
   // Playtime 2
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Total time played on this character: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_total_time_played_on_this_character' style='width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>B. System Information </strong></td>\n";
   // System specs
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>System specs: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_system_specs' style='width:370px;' /></td>\n";
   // Microphone
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you have a microphone? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_a_microphone' style='width:370px;' /></td>\n";
   // Vetrilo
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Can you use Ventrilo? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_can_you_use_ventrilo' style='width:370px;' /></td>\n";
   // Disconnects
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you have any disconnection problem at all? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_any_disconnection_problems_at_all' style='width:370px;' /></td>\n";
   // FPS
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Average FPS in raid during a boss encounter? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_avarage_fps_in_raid_during_a_boss_encounter' style='width:370px;' /></td>\n";
   // Ping
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Average latency while raiding? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_avarage_latency_during_raiding' style='width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>C. Raiding and Character Information </strong></td>\n";
   // Character
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Character Name Spec Class: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_character_name_spec_class' style='width:370px;' /></td>\n";
   // Armory
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Armory Link: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_armory_link' style='width:370px;' /></td>\n";
   // Sons of Hodir
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Are you exalted with Sons of Hodir? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_are_you_exalted_with_sons_of_hodir' style='width:370px;' /></td>\n";
   // Vanilla WoW EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Vanilla WoW experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_vanilla_wow_experience' style='width:370px;' /></td>\n";
   // TBC EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>The Burning Crusade experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_the_burning_crusade_experience' style='width:370px;' /></td>\n";
   // WotLK EXP
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Wrath of the Lich King experience: </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_wrath_of_the_lich_king_experience' style='width:370px;' /></td>\n";
   // Leader
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Have you ever been a raidleader or guildmaster? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_have_you_ever_been_a_raidleader_or_guildmaster' style='width:370px;' /></td>\n";
   // Elixirs
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you have the will and time to put in enough effort flasks and consumables for the raid? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_have_the_will_and_time_to_put_in_enough_effort_flasks_and_consumables_for_the_raid' style='width:370px;' /></td>\n";
   // Tactics
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Will you come to a progression raid having already read any available information relevant to encounters? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_will_you_come_to_a_progression_raid_having_already_read_any_available_information_relevant_to_encounters' style='width:370px;' /></td>\n";
   // Raidtime
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>What do you think about beginning raids early and staying beyond the required raid times to down new content? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_do_you_think_about_beginning_raids_early_and_staying_beyond_the_required_raid_times_to_down_new_content' style='width:370px;' /></td>\n";
   echo "</tr>\n<tr>\n";
      echo "<td class='tbl2' colspan='2'><strong>D. Other Questions </strong></td>\n";
   // Current guild
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>What guild are you currently in? Who is/was the GM? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_guild_are_you_currently_in_?_Who_is/was_the_GM' style='width:370px;' /></td>\n";
   // Current guild history
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Why are you leaving your current guild? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_why_are_you_leaving_your_current_guild' style='width:370px;' /></td>\n";
   // Activity
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you play actively outside of raiding? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_play_actively_outside_of_raiding' style='width:370px;' /></td>\n";
   // Bench time
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>There will be Bench time. Everyone will have to sit at one point in time or another. Are you okay with this? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_there_will_be_Bench_time._everyone_will_have_to_sit_at_one_point_in_time_or_another._Are_you_okay_with_this' style='width:370px;' /></td>\n";
   // Interested in joining
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Why are you interested in joining Duality? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_why_are_you_interested_in_joining_duality' style='width:370px;' /></td>\n";
   // Referaals
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>Do you currently know anyone in Duality? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_do_you_currently_know_anyone_in_duality' style='width:370px;' /></td>\n";
   // Referaals
      echo "</tr>\n<tr>\n";
      echo "<td class='tbl1'>What kind of raider can we expect you to be? </td>\n";
      echo "<td class='tbl1'><input type='text' class='textbox' name='form_what_kind_of_raider_can_we_expect_you_to_be' style='width:370px;' /></td>\n";
   // Submit Form
   echo "</tr>\n<tr>\n";
   echo "<td class='tbl1'></td>\n";
   echo "<td class='tbl1'>";
   echo "<input type='submit' class='button' name='submit_form' value='Submit' />\n";
   echo "<input type='reset' class='button' name='reset_form' value='Reset' /></td>\n";
   echo "</tr>\n</table>\n</form>\n";

|             NO EDIT BELLOW THIS NEEEDED             |
if (!function_exists("stripos")) {
   function stripos($haystack, $needle){
       return strpos($haystack, stristr( $haystack, $needle ));

if (isset($_POST['submit_form'])) {
   $message = "";
   $subject = "Unknown Name";
   while (list($key, $value) = each($_POST)) {
      if (stripos($key, "form_") === 0) {
         if ($key == $form_settings['subject_key']) {
            $subject = $form_settings['subject_prefix'].stripinput($value);
         $new_key = str_replace("form_", "", $key);
         $new_key = str_replace("_", " ", $new_key);
         $new_key = ucwords(ucfirst($new_key));
         $message .= "[b]$new_key:[/b]\n".stripinput($value)."\n\n";
   $result = dbquery("INSERT INTO ".DB_THREADS." (
   ) VALUES (
   $thread_id = mysql_insert_id();
   $result = dbquery("INSERT INTO ".DB_POSTS." (
   ) VALUES (
   $post_id = mysql_insert_id();
   $result = dbquery("UPDATE ".DB_FORUMS." SET forum_lastpost='".time()."', forum_postcount=forum_postcount+1, forum_threadcount=forum_threadcount+1, forum_lastuser='".$userdata['user_id']."' WHERE forum_id='".$form_settings['forum_id']."' LIMIT 1");
   $result = dbquery("UPDATE ".DB_THREADS." SET thread_lastpostid='".$post_id."' WHERE thread_id='".$thread_id."' LIMIT 1");
   $result = dbquery("UPDATE ".DB_USERS." SET user_posts=user_posts+1 WHERE user_id='".$userdata['user_id']."' LIMIT 1");

$country_list = array(
   "Antigua and Barbuda",
   "Bosnia and Herzegovina",
   "Burkina Faso",
   "Cape Verde",
   "Central African Republic",
   "Congo (Brazzaville)",
   "Costa Rica",
   "Cote d'Ivoire",
   "Czech Republic",
   "Dominican Republic",
   "East Timor (Timor Timur)",
   "El Salvador",
   "Equatorial Guinea",
   "Gambia, The",
   "Korea, North",
   "Korea, South",
   "Marshall Islands",
   "New Zealand",
   "Papua New Guinea",
   "Saint Kitts and Nevis",
   "Saint Lucia",
   "Saint Vincent",
   "San Marino",
   "Sao Tome and Principe",
   "Saudi Arabia",
   "Serbia and Montenegro",
   "Sierra Leone",
   "Solomon Islands",
   "South Africa",
   "Sri Lanka",
   "Trinidad and Tobago",
   "United Arab Emirates",
   "United Kingdom",
   "United States",
   "Vatican City",

$country_opts = ""; $sel = ""; $selected = "";
while(list($key, $country) = each($country_list)){
   $sel = ($country == $selected ? " selected='selected'" : "");
   $country_opts .= "<option".$sel.">".$country."</option>\n";

opentable("Application Form");

echo "<!-- Application From Made by Starefossen @ <a href=''></a> -->";

require_once THEMES."templates/footer.php";

I've added my fields, but one thing is making me sad - ucwords.
When someone filled the application, it is automatically posted on the forums.
But the problem is, every word in questions in the application Starts With Big Letter.
I've read something about ucwords, but I have no clue how to completely remove it from the application. By ucwords im able to make everything lowercase, or CAPSLOCKED, but I just simply want the sentence to start with big letter, every other words should be lower-case for every question.

Thanks in advance.
Try this? I just removed the ucwords function. Should work o.o

Also, this version makes everything else in the string lowercase.
Maybe you can try ucfirst instead of ucwords. Here is example:

Thank you so much, it worked Smile

Another thing:
As you can see, a thread name is actually

$form_settings['subject_key']      = "form_character_name_spec_class";

Is there any chance i put 3 different forms in it? Such as I want to be a forum thread name like this:
Application: "form_name" - "form_spec" "form_class".

For example, if I fill my name as Saarg, spec as Protection and class as Warrior, it will be shown:
Saarg - Protection Warrior

Related topics
Windows Tips&tricks!
Cricket : India Pakistan One Day Series
Getting rid of extension (.htm, .html, .shtml, etc.)
Only whites can be racist
A question for all you monotheists.
See how I have got this spam?
A rant on God, religion and morality
php form getting users IP address
getting rid of smoke damage
Do u read the Bible, here is a verse
Application form - onSubmit='return false;
5 myths about getting rid of the bomb
Apartment Hunting - Application Process
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.