here the code,


$a = $_GET['Cors'];
$b = $_GET['sem'];
$c = $_GET['yrlvl'];

mysql_connect("localhost", "root", "") or die ('Error'.mysqlerror());

$query="INSERT INTO sked (crs,sm,yrlvl) values ('".$a."','".$b."','".$c."')";

mysql_query($query) or die ('Error Cannnot Insert Records!');



the listbox is "sem", tnx
Member Avatar

You don't seem to mention the nature of the problem.

It may be that your options in the select widget (listbox) do not have a value. It is the value of the option tag that will be passed to the $_POST['sem'] variable not the text displayed in the widget.

<select id="sem">
  <option value = "Wales">Cymru</option>
  <option value = "Scotland">Alba</option>
  <option value = "Brittany">Breizh</option>

If the 'Cymru' option was selected in the listbox, then the $_POST['sem'] value will be 'Wales'.

If you are able to set the value attribute to the same as the text, this should sort it out.
If you can't do this for some reason, you could use javascript to programmatically set the value of the selected option to the displayed text prior to submission with an 'onsubmit' attribute.

Your line:

$query="INSERT INTO sked (crs,sm,yrlvl) values ('".$a."','".$b."','".$c."')";

Seems a little clunky and possibly dangerous. Clean your variables before passing it to the sql query:

$a = addslashes(htmlentities($_POST[...]));

$query="INSERT INTO sked SET crs = '{$a}', sm = '{$b}',yrlvl ='{$c}';

If this is not the case, come back and explain your problem.