FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Application form - getting rid of ucwords





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

Code:

<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| 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 www.gnu.org/licenses/agpl.html. 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                |
+--------------------------------------------------------*/
/*
   IMPORTANT
   ALL FORM INPUTS MUST START WITH form_ OR ELSE THEY WILL NOT BE SUBMITTED
   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." (
      forum_id,
      thread_subject,
      thread_author,
      thread_views,
      thread_lastpost,
      thread_lastpostid,
      thread_lastuser,
      thread_postcount,
      thread_poll,
      thread_sticky,
      thread_locked
   ) VALUES (
      '".$form_settings['forum_id']."',
      '".$subject."',
      '".$userdata['user_id']."',
      '0',
      '".time()."',
      '0',
      '".$userdata['user_id']."',
      '1',
      '0',
      '0',
      '0'
   )");
   $thread_id = mysql_insert_id();
   $result = dbquery("INSERT INTO ".DB_POSTS." (
      forum_id,
      thread_id,
      post_message,
      post_showsig,
      post_smileys,
      post_author,
      post_datestamp,
      post_ip,
      post_edituser,
      post_edittime
   ) VALUES (
      '".$form_settings['forum_id']."',
      '".$thread_id."',
      '".$message."',
      '1',
      '1',
      '".$userdata['user_id']."',
      '".time()."',
      '".USER_IP."',
      '0',
      '0'
   )");
   $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");
   redirect(BASEDIR."forum/viewthread.php?thread_id=".$thread_id."&pid=".$post_id."#post_".$post_id);
}

$country_list = array(
   "Afghanistan",
   "Albania",
   "Algeria",
   "Andorra",
   "Angola",
   "Antigua and Barbuda",
   "Argentina",
   "Armenia",
   "Australia",
   "Austria",
   "Azerbaijan",
   "Bahamas",
   "Bahrain",
   "Bangladesh",
   "Barbados",
   "Belarus",
   "Belgium",
   "Belize",
   "Benin",
   "Bhutan",
   "Bolivia",
   "Bosnia and Herzegovina",
   "Botswana",
   "Brazil",
   "Brunei",
   "Bulgaria",
   "Burkina Faso",
   "Burundi",
   "Cambodia",
   "Cameroon",
   "Canada",
   "Cape Verde",
   "Central African Republic",
   "Chad",
   "Chile",
   "China",
   "Colombi",
   "Comoros",
   "Congo (Brazzaville)",
   "Congo",
   "Costa Rica",
   "Cote d'Ivoire",
   "Croatia",
   "Cuba",
   "Cyprus",
   "Czech Republic",
   "Denmark",
   "Djibouti",
   "Dominica",
   "Dominican Republic",
   "East Timor (Timor Timur)",
   "Ecuador",
   "Egypt",
   "El Salvador",
   "Equatorial Guinea",
   "Eritrea",
   "Estonia",
   "Ethiopia",
   "Fiji",
   "Finland",
   "France",
   "Gabon",
   "Gambia, The",
   "Georgia",
   "Germany",
   "Ghana",
   "Greece",
   "Grenada",
   "Guatemala",
   "Guinea",
   "Guinea-Bissau",
   "Guyana",
   "Haiti",
   "Honduras",
   "Hungary",
   "Iceland",
   "India",
   "Indonesia",
   "Iran",
   "Iraq",
   "Ireland",
   "Israel",
   "Italy",
   "Jamaica",
   "Japan",
   "Jordan",
   "Kazakhstan",
   "Kenya",
   "Kiribati",
   "Korea, North",
   "Korea, South",
   "Kuwait",
   "Kyrgyzstan",
   "Laos",
   "Latvia",
   "Lebanon",
   "Lesotho",
   "Liberia",
   "Libya",
   "Liechtenstein",
   "Lithuania",
   "Luxembourg",
   "Macedonia",
   "Madagascar",
   "Malawi",
   "Malaysia",
   "Maldives",
   "Mali",
   "Malta",
   "Marshall Islands",
   "Mauritania",
   "Mauritius",
   "Mexico",
   "Micronesia",
   "Moldova",
   "Monaco",
   "Mongolia",
   "Morocco",
   "Mozambique",
   "Myanmar",
   "Namibia",
   "Nauru",
   "Nepa",
   "Netherlands",
   "New Zealand",
   "Nicaragua",
   "Niger",
   "Nigeria",
   "Norway",
   "Oman",
   "Pakistan",
   "Palau",
   "Panama",
   "Papua New Guinea",
   "Paraguay",
   "Peru",
   "Philippines",
   "Poland",
   "Portugal",
   "Qatar",
   "Romania",
   "Russia",
   "Rwanda",
   "Saint Kitts and Nevis",
   "Saint Lucia",
   "Saint Vincent",
   "Samoa",
   "San Marino",
   "Sao Tome and Principe",
   "Saudi Arabia",
   "Senegal",
   "Serbia and Montenegro",
   "Seychelles",
   "Sierra Leone",
   "Singapore",
   "Slovakia",
   "Slovenia",
   "Solomon Islands",
   "Somalia",
   "South Africa",
   "Spain",
   "Sri Lanka",
   "Sudan",
   "Suriname",
   "Swaziland",
   "Sweden",
   "Switzerland",
   "Syria",
   "Taiwan",
   "Tajikistan",
   "Tanzania",
   "Thailand",
   "Togo",
   "Tonga",
   "Trinidad and Tobago",
   "Tunisia",
   "Turkey",
   "Turkmenistan",
   "Tuvalu",
   "Uganda",
   "Ukraine",
   "United Arab Emirates",
   "United Kingdom",
   "United States",
   "Uruguay",
   "Uzbekistan",
   "Vanuatu",
   "Vatican City",
   "Venezuela",
   "Vietnam",
   "Yemen",
   "Zambia",
   "Zimbabwe"
);

$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");
application_form($country_opts);
closetable();

echo "<!-- Application From Made by Starefossen @ <a href='http://dev.starefossen.com'>www.starefossen.com</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.
Hogwarts
Try this? I just removed the ucwords function. Should work o.o

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

http://us2.php.net/manual/en/function.ucfirst.php

Sonam
Asis
Thank you so much, it worked Smile

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

$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

Cheers!
Related topics
Windows Tips&tricks!
Shoutbox?
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

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.