Jump to content

Passing Variables from database populated selection box


rbama

Recommended Posts

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----------------------------->

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'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.