I have a problem with the following code, Can someone please explain if there is anything wrong with this code?
when this file is uploaded the line that i have highlighted in red below, does not work! its a button that should 'Add' the list once it has been filled out (its actually a form). But i dont know why it dosent? i have the same problem with another file too.
PLZ HELP!!
<?
include 'db_param.php';
include 'common.php';
include 'header.inc.php';
?>
<html>
<head>
<basefont face="Verdana" size="1">
</head>
<body bgcolor=white>
<?
if (!isset($submit))
{
$link = mysql_connect($db_h, $db_u, $db_p) or exit ("Could not connect !");
mysql_select_db($db) or exit ("Could not connect to database") or exit ("Could not connect to database") ;
?>
<table border="0" cellspacing="5" cellpadding="2">
<form action="<? echo $PHP_SELF; ?>" method="POST">
<!-- job details -->
<tr>
<td>Job Number<font color="red">*</font></td>
</tr>
<tr>
<td><input type="text" name="jnum" size="10" maxlength="10"></td>
</tr>
<tr>
<td>Title<font color="red"></font></td>
<td width=30> </td>
<td>Department<font color="red"></font></td>
</tr>
<tr>
<td><input type="text" name="jtitle" size="25"></td>
<td width=30> </td>
<td><select name="depart">
<?
// get department list
$sql = "SELECT d_id, dep from depart";
$query = mysql_query($sql) or exit ("Error in query: $sql. " . mysql_error());
while (list($id, $department) = mysql_fetch_row($query))
{
echo "<option value=$id>$department</option>";
}
mysql_free_result($query);
?>
</select></td>
</tr>
<tr>
<td>Location<font color="red"></font></td>
<td width=30> </td>
<td>Salary<font color="red"></font></td>
</tr>
<tr>
<td><select name="location">
<?
$sql = "SELECT l_id, location from location";
$query = mysql_query($sql) or exit ("Error in query: $sql. " . mysql_error());
while (list($id, $location) = mysql_fetch_row($query))
{
echo "<option value=$id>$location</option>";
}
mysql_free_result($query);
?>
</select></td>
<td width=30> </td>
<td><select name="salary">
<?
$sql = "SELECT s_id, salary from salary";
$query = mysql_query($sql) or exit ("Error in query: $sql. " . mysql_error());
while (list($id, $salary) = mysql_fetch_row($query))
{
echo "<option value=$id>$salary</option>";
}
mysql_free_result($query);
mysql_close($link);
?>
</select></td>
</tr>
<tr>
<td>Responsibilities<font color="red"></font></td>
<td width=30> </td>
<td>Qualifications<font color="red"></font></td>
</tr>
<tr>
<td><textarea name="jresp" cols="40" rows="8"></textarea></td>
<td width=30> </td>
<td><textarea name="jreq" cols="40" rows="8"></textarea></td>
</tr>
<tr>
<td>Contact person<font color="red"></font></td>
<td width=30> </td>
<td>Email address<font color="red"></font></td>
</tr>
<tr>
<td><input type="text" name="jcont" size="25"></td>
<td width=30> </td>
<td><input type="text" name="contmail" size="25"></td>
</tr>
<tr>
<td align=center colspan=3><input type="submit" name="submit" value="Add Listing"></td>
</tr>
</table>
</form>
<?
}
else
{
$errorList = array();
$list = 0;
if (empty($jnum))
{ $errorList[$list] = "Invalid entry: Job code"; $list++; }
if (empty($jtitle))
{ $errorList[$list] = "Invalid entry: Job Title"; $list++; }
if (empty($jresp))
{ $errorList[$list] = "Invalid entry: Responsibilities"; $list++; }
if (empty($jreq))
{ $errorList[$list] = "Invalid entry: Qualifications"; $list++; }
if (empty($jcont))
{ $errorList[$list] = "Invalid entry: Contact"; $list++; }
if (empty($contmail) || mail_check($contmail))
{ $errorList[$list] = "Invalid entry: Contact Email "; $list++; }
if (sizeof($errorList) == 0)
{
$link = mysql_connect($db_h, $db_u, $db_p) or exit ("Could not connect !");
mysql_select_db($db) or exit ("Could not connect to database") ;
$sql = "INSERT INTO job (j_num, j_title, j_resp, j_req, j_cont, cont_mail, posted, depart, location, salary) VALUES ('$jnum', '$jtitle', '$jresp', '$jreq', '$jcont', '$contmail', NOW(), '$depart', '$location', '$salary')";
$query = mysql_query($sql) or exit ("Error in query: $sql. " . mysql_error());
mysql_close($link);
echo "Added Successfully.<p><a href=$PHP_SELF>Add another</a>, or return to <a href=jobs.php>jobs</a>";
}
else
{
err();
}
}
?>
<?
include 'footer.inc.php';
?>
</body>
</html>