Deanznet Posted February 23, 2008 Share Posted February 23, 2008 I cant get this... Its confusing me.. $dbname = 'Mydb'; mysql_select_db($dbname); if(isset($_POST['submit'])) { if(isset($_POST['item_desc']) && isset($_POST['item_price']) && isset($_POST['item_quality']) && isset($_POST['item_title'])) { if(is_numeric($_POST['item_price'])) { $item_desc = mysql_real_escape_string(htmlentities($_POST['item_desc'], ENT_NOQUOTES)); $item_quality = mysql_real_escape_string(htmlentities($_POST['item_quality'], ENT_NOQUOTES)); $item_title = mysql_real_escape_string(htmlentities($_POST['item_title'], ENT_NOQUOTES)); $item_sellback = $_POST['item_price']/2; if(mysql_query("INSERT INTO items_dict (item_desc,item_price,item_sellback,item_quality,item_title) VALUES ('" . $item_desc . "','" . $_POST['item_price'] . "','" . $item_sellback . "','" . $item_quality . "','" . $item_title . "')")) { $item_id_query = mysql_query("SELECT * FROM items_dict WHERE item_title='" . $item_title . "'") or die (mysql_error()); $item_id_array = mysql_fetch_array($item_id_query); $item_id = $item_id_array['item_id']; if(mysql_query("INSERT INTO items_store (item_id) VALUES (" . $item_id . ")")) { print '<center><b>Item created'; } else { print 'Failed connecting to the server. Please contact an admin with this error: ' . mysql_error(); } } else { print 'Failed connecting to the server. Please contact an admin with this error: ' . mysql_error(); } } else { print 'The item price must be a numerical value'; } } else { print 'You must fill out all of the data'; } } else { print '<form action=' . $_SERVER['PHP_SELF'] . ' method=post>'; print '<center><b>Add item to store<hr></b> <br /><br />'; print '<center>Item title: <br />'; print '<center><input name=item_title type=text /><br />'; print '<center>Item quality: <br />'; print '<center><input name=item_quality type=text /><br />'; print '<center>Item description: <br />'; print '<center><textarea name=item_desc></textarea><br />'; print '<center>item Price: <br />'; print '<center><input type=number name=item_price /><br />'; print '<center><input type=submit name=submit value=Submit />'; print '<center></form>'; } Thats my code that uploads text. I need it to have a feild to upload a picture.. Can someone help Quote Link to comment Share on other sites More sharing options...
phpSensei Posted February 23, 2008 Share Posted February 23, 2008 Create a File field in which your user can select the picture, and use this little tutorial to guide you through the rest, I can't write down the code for you: http://w3schools.com/php/php_file_upload.asp Quote Link to comment 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.