i have a form that uses the post function however i am having some troble getting information from the drop down menus. and also i am having some trouble doing some form validation. the code for both files is shown below.

<html><title>Create a new Prequisite Rule </title>
<body>

<form action="insert_rule.php" method="post">

Rule Label: 
<input type="text" name="rulelabel" /></p>
<p>
Rule Description: 
<input type="text" name="ruledescription" /></p>
<p>



Error Message: 
<input type="text" name="errormessage" /></p>
<p>




Select Course
<select name="course">
<option value="ecng1000">ECNG1000 Electrical Circuits</option>
<option value="ecng1010">Communicatioin Skills for Engineers</option>
<option value="ecng1012">Engingeering Science and Technology</option>
<option value="math1180">Engineering Mathematics</option>
<option value="ecng1006">Laborty and Project design 1</option>
<option value="ecng1009">Introduction to Programming</option>
<option value="ecng1013">Intorduction to Thermdynamics</option>
<option value="ecng1014">Digital Electronics</option>
<option value="ecng1015">Introduction to Electricalenergy Systems</option>
<option value="ecng1016">Mathematics for Electrical Engineers 1</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
</select>



<p>
Select Prequisite Course
<select name="prerequsite">
<option value="ecng1000">ECNG1000 Electrical Circuits</option>
<option value="ecng1010">Communicatioin Skills for Engineers</option>
<option value="ecng1012">Engingeering Science and Technology</option>
<option value="math1180">Engineering Mathematics</option>
<option value="ecng1006">Laborty and Project design 1</option>
<option value="ecng1009">Introduction to Programming</option>
<option value="ecng1013">Intorduction to Thermdynamics</option>
<option value="ecng1014">Digital Electronics</option>
<option value="ecng1015">Introduction to Electricalenergy Systems</option>
<option value="ecng1016">Mathematics for Electrical Engineers 1</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
<option value="ecng1011">Electronics</option>
</select>
</p>
<p>
<input type="submit" />
</p>
</form>
</body>
</html>

the above code is the file that contains the form. this code is still not complete since the option electronics is repeated so many times cause i just wanted to try and c if what i had is working before i proceed.

<?php

$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";

$con = mysql_connect("$hostname","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("$database", $con);

$label=$_POST[rulelabel];
$description=$_POST[ruledescription];
$course_1=$_POST[course];
$prerequsite_1=$_POST[prerequsite];
$errormsg=$_POST[errormessage];
$type="exam year";
$status="pass";

//if ($status=="pass")

    //echo"$type";
    //$cour="SELECT level_no,sem_no FROM courses WHERE course_code='$course_1'";
    //$pre="SELECT level_no,sem_nos FROM courses WHERE course_code='$prerequsite_1'";

    //if ($result=mysql_query($cour))
        //echo '<p>nice</p>';
        //else
        //echo 'good shit';
        //if ($result_1=mysql_query($pre))
        //echo '<p>nice</p>';
        //else
        //echo 'good shit 1 ';

        //$row = mysql_fetch_row($result)
        //$row_1 = mysql_fetch_row($result_1)
        //if (row[0]>=row_1[0] && row[1]>row_1[1])// row[0] should contain the level and row[1] should contain the semester no
        //{
            echo "$prerequsite_1,$status";
            $para= array($prerequsite_1,$status);
            echo "$para";
            //$parmaters= implode(",",$para);// implode function not working 

        //}


$sql="INSERT INTO rules (label,rule_description,type,parameters,error_message)
VALUES
('$label','$description','$type','$parameters','$errormsg')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 New Rule Created";

mysql_close($con)

?>

this is the php file that handles the data that is collected from the file. right now as it stands i am able to get all the variables except those from the drop down menus
and also i want to write some code that checks the the course is of a higher level number than the perquisite course however if it is the same then the semester number of the course must be higher that than that of the prerequisite course . that is what i was trying to do with lines 19-39 but continually getting an error that was referring to line 39

Hey,

Try adding quotes ' ' or " ". Interesting that the others work without the quotes, as far as I am aware, that's php structure.

$label=$_POST['rulelabel'];
$description=$_POST['ruledescription'];
$course_1=$_POST['course'];
$prerequsite_1=$_POST['prerequsite'];
$errormsg=$_POST['errormessage'];

You can use the php line to test the output.

echo $description;

P.S You might not want to publicly post passwords again. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.