php SQL查询的问题

I am new to the whole php sql thing and I am trying to build a form and insert data from its fields to an sql table. My problem is that only the first field inserts the data. Here is code.

    <html>
<head>
<title>Add New Record in MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost';
$dbuser = 'user348';
$dbpass = 'anbidVio';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

if(! get_magic_quotes_gpc() )
{
   $emp_name = addslashes ($_POST['emp_name']);
   $emp_address = addslashes ($_POST['emp_address']);
}
else
{
   $emp_name = $_POST['emp_name'];
   $emp_address = $_POST['emp_address'];
}
$emp_salary = $_POST['emp_salary'];

$sql = "INSERT INTO projectdb ".
       "(name, lastname, email, phone, position, hotelname, gender, adress) ".
       "VALUES('$emp_name','$emp_lname','$emp_mail', '$emp_phone', '$emp_job', '$emp_hotel', '$emp_gender', '$emp_adress' )";
mysql_select_db('user348_db2');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully
";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Name</td>
<td><input name="emp_name" type="text" id="emp_name"></td>
</tr>
<tr>
<td width="100">Last Name</td>
<td><input name="emp_lname" type="text" id="emp_lname"></td>
</tr>
<tr>
<td width="100">Email</td>
<td><input name="emp_mail" type="text" id="emp_mail"></td>
</tr>
<tr>
<td width="100">Phone</td>
<td><input name="emp_phone" type="text" id="emp_phone"></td>
</tr>
<tr>
<td width="100">Τύπος Εργασίας</td>
<td>
<select name="tasks" id="emp_job">
<option value="task1" >Tour Operator</option>
<option value="task2" selected="selected">Υπάλληλος</option>
<option value="task3">Διεύθυνση</option></td>
</tr>
<tr>
<td width="100">Ξενοδοχείο</td>
<td><select name="tasks"id="emp_hotel">
<option value="task1" >Village Heights</option>
<option value="task2" selected="selected">Agapi Beach</option>
<option value="task3">Malia Park</option>
<option value="task3">Blue Palace</option>
<option value="task3">Koutouloufari Apartments</option></td>
</tr>
<tr>
<td width="100">Φύλο</td>
<td><input type="radio" name="gender" id="emp_gender" value="female">Θήλυ
<input type="radio" name="gender" id="emp_gender" value="male">Άρρεν</td>
</tr>
<tr>
<td width="100">Address</td>
<td><input name="emp_address" type="text" id="emp_addres"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Employee">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>

All help will be appreciated. Thank you very much!

Properly get the data for all the input elements and then you insert it iF you had got the values properly then post your code fully

Try this

<html>
<head>
<title>Add New Record in MySQL Database</title>
</head>
<body>
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost';
$dbuser = 'user348';
$dbpass = 'anbidVio';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db('user348_db2');
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

if(! get_magic_quotes_gpc() )
{
   $emp_name = addslashes ($_POST['emp_name']);
   $emp_address = addslashes ($_POST['emp_address']);
}
else
{
   $emp_name = $_POST['emp_name'];
   $emp_address = $_POST['emp_address'];
}
$emp_salary = $_POST['emp_salary'];

$sql = "INSERT INTO projectdb (name, lastname, email, phone, position, hotelname, gender, adress) 
       VALUES('".$emp_name."','".$emp_lname."','".$emp_mail."','".$emp_phone."', '".$emp_job."', '".$emp_hotel."', '".$emp_gender."', '".$emp_adress."' )";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully
";
mysql_close($conn);
}

?>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Name</td>
<td><input name="emp_name" type="text" id="emp_name"></td>
</tr>
<tr>
<td width="100">Last Name</td>
<td><input name="emp_lname" type="text" id="emp_lname"></td>
</tr>
<tr>
<td width="100">Email</td>
<td><input name="emp_mail" type="text" id="emp_mail"></td>
</tr>
<tr>
<td width="100">Phone</td>
<td><input name="emp_phone" type="text" id="emp_phone"></td>
</tr>
<tr>
<td width="100">Τύπος Εργασίας</td>
<td>
<select name="tasks" id="emp_job">
<option value="task1" >Tour Operator</option>
<option value="task2" selected="selected">Υπάλληλος</option>
<option value="task3">Διεύθυνση</option></td>
</tr>
<tr>
<td width="100">Ξενοδοχείο</td>
<td><select name="tasks"id="emp_hotel">
<option value="task1" >Village Heights</option>
<option value="task2" selected="selected">Agapi Beach</option>
<option value="task3">Malia Park</option>
<option value="task3">Blue Palace</option>
<option value="task3">Koutouloufari Apartments</option></td>
</tr>
<tr>
<td width="100">Φύλο</td>
<td><input type="radio" name="gender" id="emp_gender" value="female">Θήλυ
<input type="radio" name="gender" id="emp_gender" value="male">Άρρεν</td>
</tr>
<tr>
<td width="100">Address</td>
<td><input name="emp_address" type="text" id="emp_addres"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Employee">
</td>
</tr>
</table>
</form>
</body>
</html>

You have error in action tag in form insted of $_PHP_SELF use $_SERVER['PHP_SELF'] for redirecting on same page