clint Posted October 21, 2009 Share Posted October 21, 2009 Hi again, I was wondering if I could please get some advice on the following I was trying. I created a form to insert data into mysql database and all is well in happyland it seems. But I would like to know if it is possible to add an option to the form to upload a picture on the same form and if it is better to upload to a second table or just use the same table. The form was to insert golf course details and display it on a profile page. That seems to be working fine, its just the uploading the image part that has me confused. (better mention, I will be doing all the uploading from what people email me, no end user input) Here is the code I have that inserts the data into the table currently. I apologize if its long. <?php $sql_insert = "INSERT into `golflist` (`name`,`user_email`,`address`,`profile`,`contact`,`country`,`state`,`city`,`tel`,`holes`,`par`,`distance`,`designer`,`fairways`,`greens`,`website`,`date` ) VALUES ('$_POST[name]','$usr_email','$_POST[address]','$_POST[profile]','$_POST[contact]','$_POST[country]','$_POST[state]','$_POST[city]','$_POST[tel]','$_POST[holes]','$_POST[par]','$_POST[distance]','$_POST[designer]','$_POST[fairways]','$_POST[greens]','$_POST[web]' ,now() ) "; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()); $user_id = mysql_insert_id($link); ?> <html> <head> <title>Insert business for sale</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" src="../js/country.js"></script> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"><p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"><p> </p> <h3 class="titlehdr">Add details for business for sale here:</h3> Or go back to Admin Panel <a href="admin_main.php">here</a>.<br> <form action="insertcourse.php" method="post" name="insertcourse" id="insertcourse" > <table width="95%" border="0" cellpadding="3" cellspacing="3" class="forms"> <tr> <td colspan="2" height="49"><font color="#FF0000">Course Name</font><font color="#CC0000">*</font><br> <input name="name" type="text" id="name" size="40"> </td> <td width="4"></td> </tr> <tr> <td colspan="2" height="21"> </td> <td></td> </tr> <tr> <td colspan="2" height="114"><font color="#FF0000">Contact Address (with ZIP)</font><font color="#CC0000">*</font><br> <textarea name="address" cols="40" rows="4" id="address"></textarea> </td> <td></td> </tr> <tr> <td height="21" valign="top" colspan="2"><font color="#FF0000"><b>Company details:</b></font></td> <td></td> </tr> <tr> <td height="59" valign="top" colspan="2"> <textarea name="profile" cols="80" rows="8" id="profile" onkeyup="if (this.value.length > 300) { alert('Character limit has been reached!'); this.value = this.value.substr(0,5); }"></textarea> </td> <td></td> </tr> <tr> <td height="21" valign="top" colspan="2"> </td> <td></td> </tr> <tr> <td height="32" width="125" valign="top"><font color="#FF0000">Contact Person</font></td> <td width="482" valign="top"> <input type="text" name="contact" id="contact"> </td> <td></td> </tr> <tr> <td height="21" colspan="2" valign="top"><font color="#FF0000" size="1">Please select your country/state</font> <font color="#FF0000">*</font></td> <td></td> </tr> <tr> <td height="27" valign="top"> <select id='countrySelect' name='country' onchange='populateState()'> </select> </td> <td valign="top"> <select id='stateSelect' name='state'> </select> <script type="text/javascript">initCountry('PLS'); </script> <td></td> </tr> <tr> <td height="40" valign="top"><font color="#FF0000">City</font></td> <td valign="top"> <input type="text" name="city" id="city"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Phone</font><font color="#CC0000">*</font> </td> <td valign="top"> <input name="tel" type="text" id="tel"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Holes</font> </td> <td valign="top"> <input name="holes" type="text" id="holes"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Par</font> </td> <td valign="top"> <input name="par" type="text" id="par"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Designer</font> </td> <td valign="top"> <input name="designer" type="text" id="designer"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Course Distance</font> </td> <td valign="top"> <input name="distance" type="text" id="distance"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Fairways Grass</font> </td> <td valign="top"> <input name="fairways" type="text" id="fairways"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Greens Grass</font> </td> <td valign="top"> <input name="greens" type="text" id="greens"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Website </font></td> <td valign="top"> <input name="web" type="text" id="web" class="optional defaultInvalid url"> <span class="example">http://www.example.com</span></td> <td></td> </tr> <tr> <td height="25" colspan="2" valign="top"> </td> <td></td> </tr> <tr> <td height="34" valign="top"><font color="#FF0000">Email Address:</font><span class="required"><font color="#CC0000">*</font></span> </td> <td valign="top"> <input name="usr_email" type="text" id="usr_email"> </td> <td></td> </tr> <tr> <td height="34"></td> <td></td> <td></td> </tr> <tr> <td height="116" valign="top"> <input name="insertcourse" type="submit" id="insertcourse" value="Update Table"> </td> <td></td> <td></td> </tr> </table> <p align="center"> </p> </form> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html> I am not looking for somebody to do the work for me, I just need advice or somebody to point me towards a tutorial that covers this....my google keywords seem to be "off par" Thank you again for taking time to read this. I REALLY do appreciate it. Quote Link to comment Share on other sites More sharing options...
Gayner Posted October 21, 2009 Share Posted October 21, 2009 You need to have insertcourse $_Post name on a if function so it knows when's to submit it. Lol something like this: if(isset($_POST['insertcourse'])){ $sql_insert = "INSERT into `golflist` (`name`,`user_email`,`address`,`profile`,`contact`,`country`,`state`,`city`,`tel`,`holes`,`par`,`distance`,`designer`,`fairways`,`greens`,`website`,`date` ) VALUES ('$_POST[name]','$usr_email','$_POST[address]','$_POST[profile]','$_POST[contact]','$_POST[country]','$_POST[state]','$_POST[city]','$_POST[tel]','$_POST[holes]','$_POST[par]','$_POST[distance]','$_POST[designer]','$_POST[fairways]','$_POST[greens]','$_POST[web]' ,now() ) "; mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error()); $user_id = mysql_insert_id($link); } I'm not sure where $link is at? or Change $_POST['whatever your form name here'] 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.