Jump to content

Recommended Posts

My problem is as follows:

 

I have a simple form, that sends several user entered variables to a MySql Database.

Problem is only the first field of the form is actually making it to the database. 

 

<html>
<head>
<title>Service Orders</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(isset($_POST['add']))
{
include 'config.php';
include 'opendb.php';


$service_order_types= $POST[service_order_types];
$client= $POST[client];
$account_executive= $POST[account_executive];
$billing_contact= $POST[billing_contact];
$client_contact= $POST[client_contact];
$due_date= $POST[due_date];
$estimate= $POST[estimate];
$quantity= $POST[quantity];
$copy_supplied= $POST[copy_supplied];
$copy_needed= $POST[copy_needed];
$size= $POST[size];
$color= $POST[color];
$black_white= $POST[black_white];
$audience= $POST[audience];
$focus= $POST[focus];
$direction= $POST[direction];
$additional_info= $POST[additional_info];
$receipients= $POST[receipients];
$required= $POST[required];
$subject= $POST[subject];


$query = "INSERT INTO `comdevin_php`.`comdev` (`id`, `service_order_type`, `client`, `account_executive`, `billing_contact`, `client_contact`, `due_date`, `estimate`, `quantity`, `copy_supplied`, `copy_needed`, `size`, `color`, `black_white`, `audience`, `focus`, `direction`, `additional_info`, `recipients`, `required`, `subject`, `extra`) VALUES ('NULL', '$service_order_type', '$client', '$account_executive', '$billing_contact', '$client_contact', '$due_date', '$estimate', '$quantity', '$copy_supplied', '$copy_needed', '$size', '$color', '$black_white', '$audience', '$focus', '$direction', '$additional_info', '$recipents', '$required', '$subject', '$extra')";


mysql_query($query) or die('Error, insert query 1');
include 'closedb.php';
echo "SUCCESS!!!";
}
else
{
?>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0" class="html">
  <tr valign="top">
    <td align="center" valign="top"><table width="750" height="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><img src="cdicreative/images/eCreative-site_01.png" alt="CDI Creative" width="750" height="204" /></td>
      </tr>
      <tr>
        <td valign="top"><table width="750" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="18" valign="top"> </td>
            <td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="140" align="center" valign="top" bgcolor="#EAF5FD"><table width="100%" height="100%" border="0" cellspacing="10" cellpadding="0">
                  <tr>
                    <td><p class="style1">service orders</p>
                      <p class="style1">whats in the works</p>
                      <p class="style1">featured artwork</p>
                      <p class="style1">client feedback</p></td>
                    </tr>
                </table>                  
                  <p class="style1"> </p></td>
                <td valign="top"><table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
                  <tr>
                    <td width="98%">
                      <form method="post">
                          <label>Service Order Type:
                          <select name="service_order_type">
                          <option selected="selected">Select from menu</option>
                          <option value="Brochures">Brochures</option>
                          <option value="Referral Cards">Referral Cards</option>
                          <option value="Posters">Posters</option>
                          <option value="BillBoard">BillBoard</option>
                          <option value="Postcards">Postcards</option>
                          <option value="Flyer">Flyer</option>
                          <option value="Newsletter">Newsletter</option>
                          <option value="Sales Folder">Sales Folder</option>
                          <option value="Advertising Campaign">Advertising Campaign</option>
                          <option value="Marketing Proposal">Marketing Proposal</option>
                          <option value="Speicalty Items">Speicalty Items</option>
                          <option value="Banners">Banners</option>
                          <option value="Photo Shoot">Photo Shoot</option>
                          <option value="Booth Space Rental">Booth Space Rental</option>
                          <option value="Furniture and Fixtures">Furniture and Fixtures</option>
                          <option value="Setup and Dismantle">Setup and Dismantle</option>
                          <option value="Hanging Signs">Hanging Signs</option>
                          <option value="Booth Hardware/Artwork">Booth Hardware/Artwork</option>
                          <option value="Hotels">Hotels</option>
                          <option value="Other">Other</option>
                                 </select>
                        </label>
                    
                        <p>
                          <label>Client Name:
                          <input type="text" name="client" id="client">
                          </label>
                          </p>
                        <p>
                            <label>Account Executive:
                              <input type="text" name="account_executive" id="account_executive" />
                            </label>
                            </p>
                        <p>
                          <label>Billing Contact
                            <input type="text" name="billing_contact" id="billing_contact" />
                          </label>
                          </p>
                        <p>
                          <label>Client Contact
                            <input type="text" name="client_contact" id="client_contact" />
                          </label>
                          </p>
                        <p>
                          <label>Due Date if Specified by Client
                            (mm/dd/yy):
                            <input name="due_date" type="text" id="due_date" size="8" />
                           </label>
                        </p>
                        <p>
                          <label>Estimate Needed:
                            <input type="checkbox" name="estimate" id="estimate" />
                          </label>
                          </p>
                        <p>
                          <label>Quantities:
                            <input type="text" name="quantity" id="quantity" />
                          </label>
                          </p>
                        <p>Copywriting:<label>Supplied
                            <input type="checkbox" name="copy_supplied" id="copy_supplied" />
                          </label>
                          
                          <label>Needed
                          <input type="checkbox" name="copy_needed" id="copy_needed" />
                          </label>
                         </p>
                        <p>
                          <label>Size:
                            <select name="size" id="size">
                            <option selected="selected">Select From Menu</option>
                            <option value="Bi-Fold Brochure">Bi-Fold Brochure</option>
                            <option value="Tri-Fold Brochure">Tri-Fold Brochure</option>
                            <option value="4 Panel Roll Fold">4 Panel Roll Fold</option>
                            <option value="5 Panel Roll Fold">5 Panel Roll Fold</option>
                            <option value="24x36 Poster">24x36 Poster</option>
                            <option value="11x17 In-House Poster">11x17 In-House Poster</option>
                            <option value="15x22 In-House Poster">15x22 In-House Poster</option>
                            <option value="Other (Details in Comments)">Other (Details in Comments)</option>
                                                      </select>
                          </label>
                          </p>
                        <p>              <label>Color
                            <input type="checkbox" name="color" id="color" />
                          </label>
                          <label>Black and White
                          <input type="checkbox" name="black_white" id="black_white" />
                          </label>
                          </p>
                        <p class="style3">Project Information</p>
                        <p>
                        <label>Who is the audience? <br />
                        <textarea name="audience" id="audience" cols="45" rows="5"></textarea>
                        <br />
                          </label>
                        </p>
                        <p>
                        <label>What does the client want to focus on? What are the details? <br />
                        <textarea name="focus" id="focus" cols="45" rows="5"></textarea>
                        <br />
                        </label>
                        </p>
                        <p>
                        <label>Any direction from the client (likes or dislikes)?
                        <textarea name="direction" id="direction" cols="45" rows="5"></textarea>
                        <br />
                        </label>
                        </p>
                        <p>
                        <label>Additional Information <br />
                        <textarea name="additional_info" id="additional_info" cols="45" rows="5"></textarea>
                        <br />
                        </label>
                        </p>
                        <p>
                          <label>
                          <input type="submit" name="add" id="add" value="Submit" />
                          </label>
                                                 </p>
                      </form>
                  
                    <!-- InstanceEndEditable --></td>
                    <td width="2%" bgcolor="#EAF5FD"> </td>
                  </tr>
                </table></td>
              </tr>

            </table></td>
            <td width="21" align="right" valign="top"> </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td valign="top"><img src="cdicreative/images/eCreative-site_05.png" alt="cdi creative" width="750" height="177" /></td>
      </tr>
    </table></td>

  </tr>

</table>

<?php
}
?>
</body>

</html>

A couple things:

 

1. First verify that all the data is received with the expected index names. Simply add this to the page:

echo "<pre>".print_r($_POST)."</pre>";

 

2. I'm not 100% sure, but your query may be misconstructed. I assume the 'id' field is an auto-incremented field. I have never seen a query where 'NULL' is sent as the value for an auto-incremented field. In fact, normally, I never see the auto-incremented fields included in INSERT queries. So, try removing the reverence from the first part of the query and remove the NULL from the VALUES section.

 

EDIT: Also, you might want to consider adding line breaks to your query code to make it easier to read.

$query = "INSERT INTO `comdevin_php`.`comdev` (`service_order_type`, `client`,
             `account_executive`, `billing_contact`, `client_contact`, `due_date`,
             `estimate`, `quantity`, `copy_supplied`, `copy_needed`, `size`, `color`,
             `black_white`, `audience`, `focus`, `direction`, `additional_info`,
             `recipients`, `required`, `subject`, `extra`)
          VALUES ('$service_order_type', '$client', '$account_executive',
             '$billing_contact', '$client_contact', '$due_date', '$estimate',
             '$quantity', '$copy_supplied', '$copy_needed', '$size', '$color',
             '$black_white', '$audience', '$focus', '$direction', '$additional_info',
             '$recipents', '$required', '$subject', '$extra')";

I changed from post to get to determine if there were any errors in the fields.

I am beginning to think that this is a MySql Problem

 

http://www.comdevinc.com/service_orders.php

 

Try this link and see if you can find a problem.

 

Thanks in advance

 

Ok, the values do appear to be getting to the page.

 

The next step would be to echo the query to the page to ensure it is properly created. I don't see any glaring errors in it. Did you try removing 'id' from the query?

Try changing

 

$service_order_types= $POST[service_order_types];

 

to

 

$service_order_types= $_POST['service_order_types'];

echo "service_order_types-".$service_order_types;

 

Notice I also added 's and _ in the POST part. look at the difference in your

$_POST['add']

$POST[service_order_types]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.