473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

adding radio buttons to form (using GBCF-V3 by Mike Cherim as a base)

Hi;

Not sure if anyone is familiar with the GBCF-V3 php contact form by Mike Cherim, but I'm using it to build a quote request form for an accounting firm. The problem is that I need to add some fields with radio buttons and while I can get them to show up just fine on the form, the values are not making it to the email that is created when the form gets sent. I'm not very good with php, so while I was able to figure out how to add additional text fields and message boxes, the radio buttons are stumping me. If any one has any idea of how to go about it, I would appreciate it!

Thanks!
Apr 29 '10 #1
2 2130
There is a separate language file for all the text values, so the code on the form page looks like this:
Expand|Select|Wrap|Line Numbers
  1. <label id="discrim" for="discrim" class="opt-label"<?php echo $discrim_errlbl; ?>><?php echo $discrim_label; ?>
  2.     <label id="discrimy" for="discrim" class="opt-label">
  3.     <input name="discrim" type="radio" value="<?php echo $discrimy_value; ?>" /><?php echo $discrimy_label; ?></label>
  4.     <label id="discrimn" for="discrim" class="opt-label">
  5.     <input name="discrim" type="radio" value="<?php echo $discrimn_value; ?>" /><?php echo $discrimn_label; ?></label>
  6.     <label id="discrima" for="discrim" class="opt-label">
  7.     <input name="discrim" type="radio" value="<?php echo $discrima_value; ?>" /><?php echo $discrima_label; ?></label>
  8.     <label id="discrimu" for="discrim" class="opt-label">
  9.     <input name="discrim" type="radio" value="<?php echo $discrimu_value; ?>" /><?php echo $discrimu_label; ?></label>
  10.     </label>
and the relevant part of the functions page seems to be here:
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['discrim'])) {
  2.     $discrimn_value = clean_var($_POST['discrimy']);
  3. }
  4. if(isset($_POST['discrim'])) {
  5.     $discrimn_value = clean_var($_POST['discrimn']);
  6. if(isset($_POST['discrim'])) {
  7.     $discrima_value = clean_var($_POST['discrima']);
  8. if(isset($_POST['discrim'])) {
  9.     $discrimu_value = clean_var($_POST['discrimu']);
  10. }  
but I'm pretty sure I'm missing something on that page, or doing it completely wrong.
Apr 29 '10 #2
Well, figured it out myself: here are the directions for anyone who needs it:

start with form.php: add in text fields or areas by copying the code already in the form and changing it to reflect the new names etc for the field. To add radio buttons, use the following:
Expand|Select|Wrap|Line Numbers
  1. <label id="typeplan" for="typeplan" class="opt-label"<?php echo $typeplan_errlbl; ?>><?php echo $typeplan_label; ?>
  2.     <label id="typeplan1" for="typeplan" class="opt-label">    <input type="radio" name="typeplan" value="<?php echo $typeplan1_label; ?>" /><?php echo $typeplan1_label; ?></label>
  3.     <label id="typeplan2" for="typeplan" class="opt-label">    <input type="radio" name="typeplan" value="<?php echo $typeplan2_label; ?>" /><?php echo $typeplan2_label; ?></label>
  4.     <label id="typeplan3" for="typeplan" class="opt-label">    <input type="radio" name="typeplan" value="<?php echo $typeplan3_label; ?>" /><?php echo $typeplan3_label; ?></label>
  5.          <label id="typeplan4" for="typeplan" class="opt-label"><input type="radio" name="typeplan" value="<?php echo $typeplan4_label; ?>" /><?php echo $typeplan4_label; ?></label>
  6.     </label>
  7.  
just change "typeplan" to whatever you want to call your item. The way I've done it you use the same verbiage from the language file for the label of each button and their values, because it's a little less to do in the language file, but I assume you can make them different if you want.
Go to your language file, for example en-us. Add the additional language as needed in the following format:
[84] PLAN TYPE LABEL TEXT * Plan Type: [85] PLAN TYPE 1 LABEL TEXT * 403 (b)
[86] PLAN TYPE 2 LABEL TEXT * 401 (k)[87] PLAN TYPE 3 LABEL TEXT * Profit Sharing
[88] PLAN TYPE 4 LABEL TEXT * Deferred Compensation
When I open it in Notepad I have boxes directly behind each number bracket, but they disappeared when I copied it to here; I am so new at this I have no idea if that makes a difference. In general follow the format already in the file. Make sure you don't have any repeat numbers in the brackets, or your file will call the wrong one.
Go to functions.php. In the language to variable assignment sections, add in your new variables and the corresponding number from the language file, like so:
Expand|Select|Wrap|Line Numbers
  1. $typeplan_label   = clean_var(lang_strip($lang_array[84]));
  2. $typeplan1_label  = clean_var(lang_strip($lang_array[85]));
  3. $typeplan2_label  = clean_var(lang_strip($lang_array[86]));
  4. $typeplan3_label  = clean_var(lang_strip($lang_array[87]));
  5. $typeplan4_label  = clean_var(lang_strip($lang_array[88]));
  6.  
Make sure they are in the same order as the language file or it will not work.
Scroll down to the posted data section. Add a new line for each field, like so:
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['typeplan'])) {
  2.     $typeplan_value = clean_var($_POST['typeplan']);
  3.  
Add a line in the exploit filter matching:
Expand|Select|Wrap|Line Numbers
  1. preg_match($inpt_expl, $typeplan_value)  ||
  2.  
and below that:
Expand|Select|Wrap|Line Numbers
  1. if(preg_match($inpt_expl, $typeplan_value)) { 
  2.     $expl_typeplan      = '<a href="#typeplan-error">'.$typeplan_label.'</a>,';
  3.     $typeplan_border    = $error_border;
  4.     $typeplan_errlbl    = $error_label;
  5.   }
  6.  
put it in the user message list below that -
Expand|Select|Wrap|Line Numbers
  1. '.$expl_typeplan.' 
  2.  
then smarten up the email by adding a section there:
Expand|Select|Wrap|Line Numbers
  1. if($typeplan_value == "") {
  2.     $typeplan_email     = "";
  3. } else {
  4.     $typeplan_email     = "   $typeplan_label : $typeplan_value\n";
  5. }
  6.  
Finally, put it in the email build here:
Expand|Select|Wrap|Line Numbers
  1. $typeplan_email
  2.  
arranging it where you want it to show up in the email.

Save and upload. You should be able to add as many additional fields as needed this way. At least, it worked for me, and if it doesn't for you at least you've got a starting point.
Apr 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Suzanne | last post by:
Hi, I have a form which our clients can fill in with their personal details. As part of the information we store there is a section - areas of interest - this is a number of radio buttons. ...
6
by: amith | last post by:
hi, i have some 10 radio buttons meant to take the rating from the user. ex: 1 2 3 4 5 6 7 8 9 10 looks O O O O O O O O O O 1 2 3 4 5 6 7 8 9 10 features O O O O O O O O O O
1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
2
by: Jeff | last post by:
I'm trying to create a dynamic form that can have multiple groups of radio buttons (each group has two buttons) with the same name. Essentially, the form allows a user to enter as many names as...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
by: Jeff Sandler | last post by:
I've seen several messages in this group with this question and no reply. Simply stated, how do you send the status of a group of radio buttons to a JavaScript function? I have a large project...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
by: kvazar | last post by:
What I am trying to create is basically a page with a bunch of multiple choice questions. Basically just like a test page. I am providing the code lower. All the questions that need to show as a part...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.