PHP Help with Form Submit | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

PHP Help with Form Submit

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-25-2009
nck nck is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 24 April 2013, 7:02 PM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Help with Form Submit

Hi,

I have a custom HTML form that has a couple radio buttons and a text field that requires a number.

I'm not a php programmer and could use some help with putting together php code to calculate a total based on the radio button selection and the text field number.

-------------------------------
Here is a snippet from the form:
<input value="$1.20 standard design" class="radio radio radio" id="$1.20 standard design" name="radio2" type="radio" />
<label for="$1.20/standard_design" class="radio_label">$1.20/standard_design</label>

<input value="$2.10 extended_design" class="radio radio radio" id="$1.20 standard design" name="radio2" type="radio" />
<label for="$2.10/extended_design" class="radio_label">$2.10/extended_design</label>

<div class="form_element cf_textbox">
<label class="cf_label">Quantity to order? *</label>
<input class="cf_inputbox required validate-number" maxlength="150" size="30" id="text_27" name="text_27" type="text" />
</div>
-------------------------------

I need PHP code to take one of the Radio button values and then multiply it by the Quantity, then from the the discount table apply the appropriate discount and save the total in a variable.

Quantity Discount table is:
50-99 10% Off 400-799 40% Off
100-199 20% Off 800-1999 50% Off
200-399 30% Off 2000-4999 60% Off

I appreciate any help with this.
Thanks
Sponsored Links
    #2  
Old 03-25-2009
ShawnMilo ShawnMilo is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 10 November 2009, 8:27 AM EST
Posts: 252
Thanks: 0
Thanked 1 Time in 1 Post
I suggest you look up "PHP tutorial" on Google, find a simple example of reading values from the $_POST object, and write some code. It doesn't matter if you get it working perfectly; you can post what you have and ask for help then.

Without showing some effort, I doubt anyone will write the code for you.
Sponsored Links
    #3  
Old 03-26-2009
nck nck is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 24 April 2013, 7:02 PM EDT
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
I know, I am working on it and will post code for help if I can get it close.

I may need to hire someone to help out.
    #4  
Old 03-26-2009
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Computer Geek
 
Join Date: Jul 2008
Last Activity: 10 July 2013, 11:06 AM EDT
Location: Frederick, MD
Posts: 748
Thanks: 4
Thanked 10 Times in 9 Posts
This should get you started.


Code:
<?php

if ($_POST) {
        $total = $_POST['radio1'] * $_POST['text_27'];
        print "Total: $".$total."<br>";
        $qty = $_POST['text_27'];
        switch ($qty) {
        case ($qty > 50 && $qty < 100):
                $dis=10;
                break;
        case ($qty > 99 && $qty < 200):
                $dis=20;
                break;


        }
print "Qty:".$qty."<br>";
print "Discount:".$dis;

} else {
?>

<form method="post" action="<?php $_SERVER['PHP_SELF'];  ?>">
<input class="radio radio radio" id="$1.20 standard design" name="radio1" type="radio" value="1.20"/>
<label for="$1.20/standard_design" class="radio_label">$1.20/standard_design</label>
<br>
<input class="radio radio radio" id="$2.10 extended design" name="radio1" type="radio" value="2.10" />
<label for="$2.10/extended_design" class="radio_label">$2.10/extended_design</label>
<br>
<div class="form_element cf_textbox">
<label class="cf_label">Quantity to order? *</label>
<input class="cf_inputbox required validate-number" maxlength="150" size="30" id="text_27" name="text_27" type="text" />
<br>
<input type="submit">
</div>
</form>

<?php
}
?>


Last edited by Ikon; 03-26-2009 at 11:20 AM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cant submit anything congo Forum Support Area for Unregistered Users & Account Problems 1 10-21-2006 02:59 PM
Cannot submit a background job tansha Shell Programming and Scripting 2 06-20-2006 09:58 AM
How to submit cron jobs? siegfried Shell Programming and Scripting 4 04-21-2006 01:52 PM
Changing Unix form to Microsoft Word form to be able to email it to someone. Cheraunm UNIX for Advanced & Expert Users 8 05-24-2002 03:58 AM



All times are GMT -4. The time now is 07:00 AM.