how do i post the data i received from the user back to specific categories in my website? here is my simple html code <html> <body> <form action="henny.php" method="POST"> Title:<input type="text" size="40" required name="title"> <br> Category:<select><br> <option value="electo">Electronics <Option value="furn">Furniture </select> Condition:<select><br> <option value="new">New <Option value="used">Used </select> Description:<input type="textarea" rows="3" cols="30" required name="descr"><br> Price: <input type="text" size="40" required name="price"><br> <input type="submit" value="Submit"> </form> </body> </html> here is my php code i just got stuck on the INSERT INTO I mean like i have 5 columns in my table but I don't know how to add those additional two name and price variables so i just repeated the category and condition columns in my php code <html> <head> <title>hennymaster</title> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("simple_login", $con); $sql="INSERT INTO Items (Title, Category, Category, Condition, Condition, Description,Price) VALUES('$_POST[title]','$_POST[electo]','$_POST[furn]','$_POST[new]','$_POST[used]','$_POST [descr]','$_POST[price]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo ""; mysql_close($con); ?> </head> <body bgcolor="black"> </body> </html>
I assume that the second bunch of code is henny.php. (If it's not, none of that will work, since that's where you're telling your form to post to.) Aside from the fact that you're not sanitizing the data you're inserting, or checking the form before submitting (don't use HTML5, please - the web has enough crap sites already), it looks as if you're asking how to store fields the table doesn't have. ("column" is in a spreadsheet, in a database you have tables with records, and each record has one or more fields.) Short answer is "you can't". Longer answer is "add fields for those variables into the table".
I am not getting the exact problem by seeing your data but if you want to work for the categories than you can do it with this. First divide your code in 2 tables 1. Categories (Id (auto number ) , Categoryname) 2. now save the other details in 2nd table use only the category id it will help you to sort according to the categories. If i am wrong than please let me know i will again reply you