Jump to content

Recommended Posts

Hi All,

          I have made a form, an "insert.php" and a DB to go along with it.

For now my form has only Fname, Lname, Address and phone. I need to add fields for Model, Descrip, Qty and Price.

 

My DB has two tables. One called customer_invoice and one called Orders.

 

Both have an ID record as well. I would like to have my form (with the name and address. . .) also have multiple fields for product model, descrip. . .

 

How can I have many fields (product area) input into the db and have the same ID as the customer? Also, how can many fields use the same name?

 

Is there a better way to do what I'm trying to accomplish?

 

Thanks in advance,

                      John

Link to comment
https://forums.phpfreaks.com/topic/136233-form-trouble/
Share on other sites

Thanks for the reply. This isn't gonna be used with a site or online in any way. Just for our local customers and for my own php practice.

 

This is what I have so far for my Create_Invoice.php

<table width="94%" border="0" align="center" cellpadding="2">
  <tr>
    <td width="10%"> </td>
    <td width="63%"><div align="center">Customer Information </div></td>
  </tr>
  <tr>
    <td class="style1">Name </td>
    <td><form action="insert.php" method="post">

      <label>
        First
        <input name="firstName" type="text" id="firstName" size="20" />
        </label>
    Last 
    <label>
    <input name="lastName" type="text" id="lastName" size="20" />
    </label>
   
      </td>
  </tr>
  <tr>
    <td class="style1">Adderess</td>
    <td><label>Street <input name="street" type="text" id="address" value="" size="40"></label><br />
<lable>City    <input name="city" type="text" id="city" value="" size="40">
</lable><br />

<lable>State  <input name="state" type="text" id="state" value="" size="5">
</lable>

<lable>Zip<input name="zip" type="text" id="zip" value="" size="8">
</lable></td>
  </tr>
  <tr>
    <td class="style1">Phone</td>
    <td><input name="phone" type="text" id="phone" size="20" /><br /><br />
     
    
    </td>
  </tr>
  <tr><td><label>
    <input name="site" type="radio" value="12volt">
    12Volt</label><label>
    <input name="site" type="radio" value="stomp">
    Stomp</label></td><td><input type="submit" name="Submit" value="Submit"></form></td></tr>
</table>

 

This is the insert.php

<?php
$con = mysql_connect("localhost","root","iforgot1");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


$date = date("F j, Y");                 // March 10, 2001


mysql_select_db("Invoicing", $con);

$sql="INSERT INTO customer_invoice (FirstName, LastName, Street, City, State, Zip, Phone, Date, Site)
VALUES
('$_POST[firstName]','$_POST[lastName]','$_POST[street]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[phone]', '$date','$_POST[site]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con)
?>

Link to comment
https://forums.phpfreaks.com/topic/136233-form-trouble/#findComment-710838
Share on other sites

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.