Darkmatter5 Posted April 23, 2008 Share Posted April 23, 2008 With this code it'll output that it entered the data into the database, but if I go to the table to verify the data was entered there is a new entry, except it's blank. Meaning the data I put in the text box wasn't put into the table. <td width="96" bgcolor="#FFDB6F"><div align="right"><span class="style8">Job Type:</span></div></td> <td width="148" bgcolor="#FFDB6F"><div align="center"> <input name="Type" type="text"> </div></td> <td width="220" bgcolor="#FFDB6F"><span class="style18 style2">Name of new job type.</span></td> <td width="183" bgcolor="#FFDB6F"><div align="center"><span class="style18 style2"> <input name="addtype" type="Submit" id="addtype" value="Submit new job type entry" /> </span></div></td> <td width="200" bgcolor="#006699"><div align="center"><span class="style7"> <?php if(isset($_POST['addtype'])) { include 'library/dbconfig.php'; include 'library/opendb.php'; $County=$_POST['Type']; //put new client data from form into the clients table $insertdata="INSERT INTO byrnjobdb.types (Type) VALUES ('$Type')"; mysql_query($insertdata) or die('Error, insert query failed'); //after new client data is applied to clients table, display success message $FNquery=mysql_query(sprintf("SELECT type FROM byrnjobdb.types WHERE Type='$Type'")); $FNresult=mysql_fetch_assoc($FNquery); echo "New Job Type ADDED..."; include 'library/closedb.php'; } else { ?> </span></div></td> Any ideas? Link to comment https://forums.phpfreaks.com/topic/102599-help-with-text-box-and-submit-button-code/ Share on other sites More sharing options...
ublapach Posted April 23, 2008 Share Posted April 23, 2008 the value is wrong it should be $country instead of $type Link to comment https://forums.phpfreaks.com/topic/102599-help-with-text-box-and-submit-button-code/#findComment-525534 Share on other sites More sharing options...
Darkmatter5 Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks, that's what I get for copy and pasting. Link to comment https://forums.phpfreaks.com/topic/102599-help-with-text-box-and-submit-button-code/#findComment-525951 Share on other sites More sharing options...
Darkmatter5 Posted April 24, 2008 Author Share Posted April 24, 2008 I have a text box a list that's generated by a query and a submit button. I know how to submit the data entered from the text box into the table, but now do I reference the data selected from the list. Here's the insert code I use. <?php if(isset($_POST['addsurvey'])) { include 'library/dbconfig.php'; include 'library/opendb.php'; $Survey=$_POST['Survey']; $SurvCounty=$_POST['SurvCounty']; //put new type data from form into the types table $insertdata="INSERT INTO byrnjobdb.surveys (Survey, SurvCounty) VALUES ('$Survey', '$SurvCounty')"; mysql_query($insertdata) or die('Error, insert query failed'); //after new survey data is applied to surveys table, display success message echo "New Survey ADDED..."; include 'library/closedb.php'; } else {} ?> And here's the code I have to construct the list. <?php include 'library/dbconfig.php'; include 'library/opendb.php'; $query=mysql_query(sprintf("SELECT County FROM byrnjobdb.counties ORDER BY County ASC")); echo "<select name='SurvCounty'>"; while ($result=mysql_fetch_assoc($query)) { $r=$result['County']; echo "<option value='$r'>$r</option>"; } echo "</select>"; include 'library/closedb.php'; ?> any ideas? Link to comment https://forums.phpfreaks.com/topic/102599-help-with-text-box-and-submit-button-code/#findComment-526026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.