bumba000 Posted December 9, 2008 Share Posted December 9, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/136233-form-trouble/ Share on other sites More sharing options...
Maq Posted December 9, 2008 Share Posted December 9, 2008 Is the customer already logged in? Where do you store the ID? I assume you do not have much done. Can we at least see the code you have already? Quote Link to comment https://forums.phpfreaks.com/topic/136233-form-trouble/#findComment-710641 Share on other sites More sharing options...
bumba000 Posted December 9, 2008 Author Share Posted December 9, 2008 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) ?> Quote Link to comment https://forums.phpfreaks.com/topic/136233-form-trouble/#findComment-710838 Share on other sites More sharing options...
bumba000 Posted December 13, 2008 Author Share Posted December 13, 2008 Bump Quote Link to comment https://forums.phpfreaks.com/topic/136233-form-trouble/#findComment-714724 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.