rbama Posted March 22, 2010 Share Posted March 22, 2010 Hi , I am having problem with my code. It returns error when i submit.My code look like this: add_newsign.php <------------------------------------------begin add_newsign.php---------------------------------------------> <form id="form1" name="form1" method="post" action="add_newsign_action.php"> <table width="499" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="135">Category</td> <td width="343"> <select name="categoryID"> <?php include("dbconnect.php"); $sql = "SELECT * FROM tblSignWordCategory "; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<option value=\"".$row['intCategoryID']."\">".$row['vcCategory']."\n "; } ?> </select> </label></td> </tr> <tr> <td>Sign Word </td> <td><input name="vcSignWord" type="text" id="vcSignWord" /></td> </tr> <tr> <td>Meaning</td> <td><textarea name="vcSignWordMeaning" cols="35" rows="7" id="vcSignWordMeaning"></textarea></td> </tr> <tr> <td>Example Sentences </td> <td><textarea name="vcSignWordUsage" cols="35" rows="7" id="vcSignWordUsage"></textarea></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan="2"><label> <div align="center"> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Reset" value="Reset" /> </div> </label></td> </tr> </table> </form> <------------------------------------------ end add_newsign.php---------------------------------------------> <-----------------------------begin add_newsign_action.php-----------------------------> <?php $intCategoryID=$_POST['intCategoryID']; $vcSignWord=$_POST['vcSignWord']; $vcSignWordMeaning=$_POST['vcSignWordMeaning']; $vcSignWordUsage=$_POST['vcSignWordUsage']; include("dbconnect.php"); $query="INSERT INTO tblSignWord (intCategoryID,vcSignWord,vcSignWordMeaning,vcSignWordUsage) VALUES ('".$intCategoryID."','".$vcSignWord."','".$vcSignWordMeaning."','".$vcSignWordUsage."')"; mysql_query($query) or die ('Error updating database'); echo "SignWord List updated with: ".$vcSignWord.""; echo " <a href='signword_list.php'>Return to SignWord list</a>"; ?> <-----------------------------end add_newsign_action.php-----------------------------> Quote Link to comment https://forums.phpfreaks.com/topic/196098-passing-variables-from-database-populated-selection-box/ Share on other sites More sharing options...
Adam Posted March 22, 2010 Share Posted March 22, 2010 It returns error when i submit. ... What's that error? Quote Link to comment https://forums.phpfreaks.com/topic/196098-passing-variables-from-database-populated-selection-box/#findComment-1029889 Share on other sites More sharing options...
rbama Posted March 22, 2010 Author Share Posted March 22, 2010 PHP Notice: Undefined index: intCategoryID in add_newsign_action.php on line 108 Quote Link to comment https://forums.phpfreaks.com/topic/196098-passing-variables-from-database-populated-selection-box/#findComment-1029896 Share on other sites More sharing options...
scvinodkumar Posted March 22, 2010 Share Posted March 22, 2010 You should use the same name what you have used in the form, but in your action file you have used different name, change the name here $intCategoryID=$_POST['intCategoryID']; to $intCategoryID=$_POST['categoryID']; Quote Link to comment https://forums.phpfreaks.com/topic/196098-passing-variables-from-database-populated-selection-box/#findComment-1029924 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.