Results 1 to 5 of 5

Thread: Automatic Quote Request Form PHP

  1. #1

    Automatic Quote Request Form PHP

    Hey there

    I'm doing a website for a printer business

    Didn't know if it was possible, but is there a way where a person can go to a web form and select the appropriate form parameters that end up creating a job description?

    When the person clicks submit, it takes them to a page that has automatically created a 'quote' depending on the parameters the user has chosen in the form previous?

    I'm thinking something to do with a mysql database here.

    Thanks for any help

  2. #2
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    It's possible, and quite easy...

    Just pass some $_POST variables from the form page to the quote page to display the quote. You can have an HTML page with a nice template and everything displaying values you calculated from their input. MySQL/any database might be overkill for this, unless you are wanting to store the information they submitted. Again though, this database could get very large and ugly, very fast (and adds unnecessary risk). I would suggest automatically emailing the results to the print company (if all input is there and valid) so they can follow up with the potential client, and giving the option for the user to print the page, email it to themselves, or whatever else. Just my 2 cents

  3. #3
    Quote Originally Posted by actionAction View Post
    It's possible, and quite easy...

    Just pass some $_POST variables from the form page to the quote page to display the quote. You can have an HTML page with a nice template and everything displaying values you calculated from their input. MySQL/any database might be overkill for this, unless you are wanting to store the information they submitted. Again though, this database could get very large and ugly, very fast (and adds unnecessary risk). I would suggest automatically emailing the results to the print company (if all input is there and valid) so they can follow up with the potential client, and giving the option for the user to print the page, email it to themselves, or whatever else. Just my 2 cents
    Thanks for your input.
    I'm trying to output a numerical value to each selection. Unfortunately, it's outputting the actual 'definer' instead of the variable itself.

    my page can be previewed at http://www.readysetprint.com.au/mathscript.php

    here's my code:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    Insert two numbers in the next form and hit submit button <br>
    <?php
    $submitform = $_SERVER['PHP_SELF'];
    ?>
    <form action="<?php echo $submitform; ?>" method="post">
    Paper parent: 
      <select name="parent" id="parent">
        <option value="mum">Mum</option>
        <option value="dad">Dad</option>
                                  </select>  
      <br />
    Printing Type:   <select name="sibling" id="sibling">
        <option value="brother">Brother</option>
        <option value="sister">Sister</option>
              </select>  
      <br />
    other:   <select name="other" id="other">
        <option value="cousin">Cousin</option>
        <option value="niece">Niece</option>
              </select> 
     
    <input type="submit" />
    </form>
    
    <? 
    
    $parent = $_POST['parent'];
    $sibling = $_POST['sibling'];
    $other = $_POST['other'];
    
    
    $a = '$'.$parent.'_'.$sibling.'_'.$other;
    
    if ($_POST['parent'])
    
    $mum_brother_niece = "200";
    $mum_brother_cousin = "250";
    
    $mum_sister_niece = "500";
    $mum_sister_cousin = "400";
    
    $dad_brother_niece = "2100";
    $dad_brother_cousin = "2500";
    
    $dad_sister_niece = "5000";
    $dad_sister_cousin = "4000";
    
    echo "The total cost is ".$a."<br />";
    
    	
    ?>
    </body>
    </html>

  4. #4
    you have to assign numerical values to the post so...
    PHP Code:
    $parent $_POST['parent'];
    if ( 
    $parent == 'mum' $parent 100;
    if ( 
    $parent == 'dad' $parent 200
    and so forth
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  5. #5
    actionAction's Avatar
    1,142
    posts
    humanBeing._beard=true;
    I haven't tested this, but here is a revised version that may help you get going in the right direction.

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    Insert two numbers in the next form and hit submit button <br>
    <?php
    $submitform 
    $_SERVER['PHP_SELF'];
    ?>
    <form action="<?php echo $submitform?>" method="post">
    Paper parent: 
      <select name="parent" id="parent">
        <option value="mum">Mum</option>
        <option value="dad">Dad</option>
                                  </select>  
      <br />
    Printing Type:   <select name="sibling" id="sibling">
        <option value="brother">Brother</option>
        <option value="sister">Sister</option>
              </select>  
      <br />
    other:   <select name="other" id="other">
        <option value="cousin">Cousin</option>
        <option value="niece">Niece</option>
              </select> 
     
    <input type="submit" />
    </form>

    <? 

    $parent 
    $_POST['parent'];
    $sibling $_POST['sibling'];
    $other $_POST['other'];

    /*
    I see where you were going with this, but it doesn't work. You are not
    actually creating a variable dynamically, you are creating a string constant
    $a = '$'.$parent.'_'.$sibling.'_'.$other;
    */

    /*
    As simplistik stated, you need to set variables that have a numeric 
    amount assigned to them, which is what you were trying to do below, however,
    since you aren't creating an actual variable with $a, it doesn't work.
    I have placed some sample code below to show you how this would work.
    */

    #I am initializing the price/quantity variables here, and then the form values
    #will give me the quantity to multiply by the price
    $parent_price 100.00;
    $parent_quantity 0;
    $sibling_price 50.00;
    $sibling_quantity 0;
    $other_price 25.00;
    $other_quantity 0;

    #If mum is chosen, quantity is one, else quantity is two
    if($parent == "mum")
    {
        
    $parent_quantity 1;
    }
    else
    {
        
    $parent_quantity 2;
    }

    #Same logic as above
    if($sibling == "sister")
    {
        
    $sibling_quantity 1;
    }
    else
    {
        
    $sibling_quantity 2;
    }

    #Same logic again
    if($other == "cousin")
    {
        
    $other_quantity 1;
    }
    else
    {
        
    $other_quantity 2;
    }

    #NOTE: I have added isset() here to check if the $_POST variable has been set
    if (isset($_POST['parent']))
    {
        
    $total 0.00;
        
    $parent_cost $parent_price $parent_quantity;
        
    $sibling_cost $sibling_price $sibling_quantity;
        
    $other_cost $other_price $other_quantity;
        
        
    $total $parent_cost $sibling_cost $other_cost;
    }
    echo 
    "The total cost is ".$total."<br />";

        
    ?>
    </body>
    </html>
    Hope it helps, let me know if you have any questions.

    _aA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012