473,473 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Modify my PHP form to ADD 3 Options?

2 New Member
Hello,

I am looking to create this function (3 options): https://www.securebiller.com/proresvera.com/order.php

Where customers can choose 3 different options, but my PHP currently only allows one option: http://www.nutraiq.com/index2.php

Questions:
1. How can I take the submit button I currently have <input name="amt" type="hidden" id="amt" value="62.53"> and change the "value" to something that I can add a "Check Box or Radio button" and add 3 options on my page then have it submit that value?

2. The other issue is that the my index2.php page will send an EMAIL with the original "Value" shown; could you also suggest a "code" to add to the EMAIL that would reflex the customers choice.

EMAIL PHP SAMPLE:
$MailBody = $MailBody . " <p>Please keep this email for your records and print it for future reference. You will see a non-refundable charge for the $62.53 on your credit card statement under the marketing firm’s name of “NGO PRODUCT” or “NGO PRODUCTS ONLINE” depending on your credit cards reporting system. So, be aware that this is a PAYMENT for your 90-Day Supply of NUTRAiQ Nutrient Rich Shampoo.</p>\r\n";

3. Then I need a "code" to add to my "thankyou" page where the "$62.53" can be replaced by the customers choice.
http://www.nutraiq.com/payment-complete.php


Thanks in Advance!
Oct 12 '09 #1
3 2173
TheServant
1,168 Recognized Expert Top Contributor
0. Welcome to Bytes.

1. You want to look at javascript for that. Javascript handles actions once the page has been sent and the user is looking at it. To use PHP, you would need to send the page again, which would involve sending the form, but that's a bit overkill. AJAX is like a hybrid, but is not needed. So using javascript you can use user events (like clicking a radio button or changing a dropdown) to do something (like change your "amt" value).

2. Once your form has been submitted, the data from your form is sent in a $_POST array. To access your $_POST variables your would have something like:
Expand|Select|Wrap|Line Numbers
  1. $amt = $_POST['amt'];
So the name of the form element is the "key" of the array. If you haven't done much of this before you should really spend some time reading about PHP forms.

3. Again, this is form handling, so once your form is finished, you can set what it displays and include something like:
Expand|Select|Wrap|Line Numbers
  1. if ($successful) {
    echo "Thanks for your \$$amt!";
    }
The "\$" is to escape the $ character (which is usually for variables) and the next $amt is for the variable previously defined.

4. You said that the input you described what your submit button? It's type is "hidden" so it will not display, and if it was a submit button teh type would be "submit"? Which do you want?
Oct 12 '09 #2
mrernesto
2 New Member
Thanks TheServant for your time.

In regards to your question about the button, if you go to my site you'll see the HTML code for the button: http://www.nutraiq.com/index2.php

HTML CODE:
<td height="25" colspan="2"><div align="center">
<input name="amt" type="hidden" id="amt" value="62.53">
<input type="image" src="images/button-60day-submit.jpg" width="224" height="49"></div></td>

My Goal is for my site to look like: https://www.securebiller.com/proresvera.com/order.php

ABOUT javascript:
In regards to the Javascript, could you please show me the JS you have in mind to add and how I can put the two elements together, i.e. "amt" and the 3 options as "My Goal" example is doing?

Thanks again for your time.
Oct 12 '09 #3
TheServant
1,168 Recognized Expert Top Contributor
Have a look at this to get s similar code to what you will need. Simply copying the code will not help and you should try to understand it and teach yourself a bit of basic javascript so you can get it working exactly how you want it.

You can change the style of a submit button, which is better (I think atleast) than using an image input.
Expand|Select|Wrap|Line Numbers
  1. /* HTML */
  2. <input name="submit" type="submit" id="submit_button" value="" />
  3.  
  4. /* CSS */
  5. #submit_button {
    color: red;
  6. background: yellow url(images/button-60day-submit.jpg) no-repeat;
  7. height: 49px;
  8. width: 224px;
  9. }
That's for your submit button. Now you can leave your hidden one to use later. Now I have to ask, why don't you process which radio button was selected once the form is submitted and do the calculation in PHP?

As in, you don't use javascript, or a hidden input but have PHP do it when you process the form like:
Expand|Select|Wrap|Line Numbers
  1. $amt = $_POST['radio_value'] * 0.834; /* Or whatever your calculation is */
This is the better choice if you're not displaying the update everytime a user clicks on a different radio button, which you're not if your input is hidden.

Have a look at this to get you started on PHP forms if you haven't already.
Oct 13 '09 #4

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

Similar topics

0
by: trysendingspam | last post by:
Hi, I want to add some interactivity on my web page, so I have a form that allows the user to display some specific elements of a XML data set. The form is populated at first from the XML data,...
3
by: % =joe % | last post by:
I cannot get this code to work. Very simple...I have three list menus. I want to do a check before the form submits to make sure that the value of the 3 fields is equal to 12. Here's my...
1
by: HJ Majoue | last post by:
I am having a problem with RichTextBox Control and hope you can help I am working on a VB.Net project that has a RTB control, the user opens a form template. What I want to do is for a user to be...
1
by: news.wanadoo.nl | last post by:
Hi, I have found whit google this form in this group. But i'n not good in javascript :(. I try and error normal but i only error now :P Whit i now want to now how can i get access to the vars...
5
by: Chris Robb | last post by:
I'm having some really odd behavior with a PHP script. I have it populating an HTML select form with a for loop. When I try the years 2006 to 1900. I get the following error: PHP Warning: ...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
1
by: jack.vier | last post by:
I have a form to add data to a table. That works like a charm. The part that doesn't work is... I have a drop-down that when its "On Change" event is triggered it will make "Visible" and...
6
by: JLupear | last post by:
I have written a code (a translation of my first one) that is not working. I did a user defined function that is used on 'onsubmit'. It should total the value from the form selections and...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.