Edit Registration form

<?php
error_reporting(0);
include("config.php");

$editID=$_GET['edit'];

$select=mysql_query("SELECT * FROM registered_user WHERE userid=$editID");

while($row=mysql_fetch_array($select))
{
/*echo "<pre>";
print_r($row);
echo "</pre>";*/

$firstname=$row['firstname'];
$middlename=$row['middlename'];
$lastname=$row['lastname'];
$username=$row['username'];
$password=$row['password'];
$decodedPassword=base64_decode($password);
$seX=$row['sex'];
$preflocation=$row['preflocation'];
$pLocation=explode(",",$preflocation);
$address=$row['address'];
$stdcode=$row['stdcode'];
$phoneno=$row['phoneno'];
$countrycode=$row['countrycode'];
$mobileno=$row['mobileno'];
$cityid=$row['city_id'];
$stateid=$row['state_id'];
$country=$row['country'];
}

$firstName=trim($_POST['txtFirstName']);
$middleName=trim($_POST['txtMiddleName']);
$lastName=trim($_POST['txtLastName']);
$userName=trim($_POST['txtUserName']);
$password=trim($_POST['txtPassword']);
$txtReTypePassword=trim($_POST['txtReTypePassword']);
$sex=$_POST['sex'];
$txtPLocation=$_POST['txtPLocation'];
$txtAreaAddress=trim($_POST['txtAreaAddress']);
$txtSTDNo=trim($_POST['txtSTDNo']);
$txtPhoneNo=trim($_POST['txtPhoneNo']);
$txtCountryCode=trim($_POST['txtCountryCode']);
$txtMobileNo=trim($_POST['txtMobileNo']);
$selectState=$_POST['selectState'];
$selectCity=$_POST['selectCity'];
$txtCountry=trim($_POST['txtCountry']);

if(isset($_POST['btnEdit']) && ($_POST['btnEdit']=="Edit"))
{
echo "<pre>";
print_r($_POST);
echo "</pre>";

/* $str=implode(",",$txtPLocation);
echo "1".$str;
echo "</pre>";*/

if(empty($firstName))
{
$strError[] .="<li>Please Enter First Name</li>";
}
if(empty($middleName))
{
$strError[] .="<li>Please Enter Middle Name</li>";
}
if(empty($lastName))
{
$strError[] .="<li>Please Enter Last Name</li>";
}
if(empty($userName))
{
$strError[] .="<li>Please Enter Username</li>";
}
if(empty($password))
{
$strError[] .="<li>Please Enter Password</li>";
}
if(empty($txtReTypePassword))
{
$strError[] .="<li>Please Re-Type Password</li>";
}
if(empty($sex))
{
$strError[] .="<li>Please Select Sex</li>";
}
if(empty($txtPLocation))
{
$strError[] .="<li>Please Select Preffered Location</li>";
}
if(empty($txtAreaAddress))
{
$strError[] .="<li>Please Enter Address</li>";
}
if(empty($txtSTDNo))
{
$strError[] .="<li>Please Enter STD Code</li>";
}
if(empty($txtPhoneNo))
{
$strError[] .="<li>Please Enter Phone No</li>";
}
if(empty($txtCountryCode))
{
$strError[] .="<li>Please Enter Country Code</li>";
}
if(empty($txtMobileNo))
{
$strError[] .="<li>Please Enter Mobile No</li>";
}
if(empty($selectState))
{
$strError[] .="<li>Please Select State</li>";
}
if(empty($selectCity))
{
$strError[] .="<li>Please Select City</li>";
}
if(empty($txtCountry))
{
$strError[] .="<li>Please Enter Country</li>";
}
if($password != $txtReTypePassword)
{
$strError[] .="<li>Password is not matched</li>";
}
if(!empty($firstName) && !empty($middleName) && !empty($lastName) && !empty($username) && !empty($password) && !empty($txtReTypePassword) && !empty($sex) && !empty($txtPLocation) && !empty($txtAreaAddress) && !empty($txtSTDNo) && !empty($txtPhoneNo) && !empty($txtCountryCode) && !empty($txtMobileNo) && !empty($selectState) && !empty($selectCity) && !empty($txtCountry))
   {
/*$mysqlSelect = "SELECT * FROM tbl_admin WHERE username='".$username."'";
$mysqlSelected = mysql_query($mysqlSelect);

$count = mysql_num_rows($mysqlSelected);

if($count > 0)
{
$strError[] .= "<li> Username is already exist </li>";
}
else*/ if($password == $txtReTypePassword)
{
$encodedPassword=base64_encode($password);
$txtPrefLocation=implode(",",$txtPLocation);

$sqlUpdateRUser = "UPDATE registered_user SET
firstname='".$firstName."',
middlename='".$middleName."',
lastname='".$lastName."',
username='".$userName."',
password='".$encodedPassword."',
sex='".$sex."',
preflocation='".$txtPrefLocation."',
address='".$txtAreaAddress."',
stdcode='".$txtSTDNo."',
phoneno='".$txtPhoneNo."',
countrycode='".$txtCountryCode."',
mobileno='".$txtMobileNo."',
state_id='".$selectState."',
city_id='".$selectCity."',
country='".$txtCountry."'
WHERE userid='".$editID."'";

$sqlUpdatedRUser = mysql_query($sqlUpdateRUser);

$sqlUpdateAdmin = "UPDATE tbl_admin SET
username='".$userName."',
password='".$encodedPassword."'
WHERE admin_id='".$editID."'";

$sqlUpdatedAdmin = mysql_query($sqlUpdateAdmin);

header('Location: useredited.php');
}
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration Form</title>
<link type="text/css" href="css/style.css" rel="stylesheet" />
</head>
<body>
<div id="regiheading">Registration Form
</div>
<div id="regiwrap" align="center">
<table width="620px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="regileftcorntop">
</td>
<td id="regiupperstrip">
</td>
<td id="regirightcorntop">
</td>
</tr>
<tr>
<td colspan="3">
<form name="registrationFrm" action="" method="post" id="registrationID" enctype="multipart/form-data" target="">
<div align="center">
<table border="0" width="620" cellspacing="0" cellpadding="5" align="center">
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td colspan="2" style="color:#FF0000; padding-left:100px;">
<?php foreach($strError as $key => $val)
 {  
echo $val;
 }
?>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">First Name :
</td>
<td id="namefields"><input type="text" name="txtFirstName" id="txtFirstNameId" value="<?php echo $firstname; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Middle Name :
</td>
<td id="namefields"><input type="text" name="txtMiddleName" id="txtMiddleNameId" value="<?php echo $middlename; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Last Name :
</td>
<td id="namefields"><input type="text" name="txtLastName" id="txtLastNameId" value="<?php echo $lastname; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Username :
</td>
<td id="namefields"><input type="text" name="txtUserName" id="txtUsernameId" value="<?php echo $username; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Password :
</td>
<td id="namefields"><input type="password" name="txtPassword" id="txtPasswordId" value="<?php echo $decodedPassword; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Re-Type Password :
</td>
<td id="namefields"><input type="password" name="txtReTypePassword" id="txtReTypePasswordId" value="<?php echo $decodedPassword; ?>" size="35"/>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Gender :
</td>
<td id="namefields"><input type="radio" name="sex" id="sexId" value="Male" <?php if($seX=='Male') echo 'checked'; ?>/>Male<span><input type="radio" name="sex" id="sexId" value="Female" <?php if($seX=='Female') echo 'checked'; ?>/>Female</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Prefferd Location :
</td>
<td id="namefields"><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Sydney" <?php if($pLocation[0]=="Sydney" || $pLocation[1]=="Sydney" || $pLocation[2]=="Sydney") echo 'checked'; ?>>Sydney<span><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Ottawa" <?php if($pLocation[0]=="Ottawa" || $pLocation[1]=="Ottawa" || $pLocation[2]=="Ottawa") echo 'checked'; ?>>Ottawa</span><span><input type="checkbox" name="txtPLocation[]" id="txtPLocationId" value="Singapore" <?php if($pLocation[0]=="Singapore" || $pLocation[1]=="Singapore" || $pLocation[2]=="Singapore") echo 'checked' ; ?>>Singapore</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Address :
</td>
<td id="namefields"><textarea cols="27" rows="5" name="txtAreaAddress" wrap=yes id="txtAreaAddressID"><?php echo $address; ?></textarea>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Phone Number :
</td>
<td id="namefields"><input type="text" name="txtSTDNo" id="txtSTDNoId" size="4" value="<?php echo $stdcode; ?>" />-<input type="text" name="txtPhoneNo" id="txtPhoneNoId" size="26" value="<?php echo $phoneno; ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td style="font-size:12px;">STD Code<span style="margin-left:50px;">Phone Number</span>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Mobile Number :
</td>
<td id="namefields"><input type="text" name="txtCountryCode" value="<?php if($countrycode!='+91') echo $countrycode; else echo '+91';  ?>" size="4"  maxlength="3" />-<input type="text" name="txtMobileNo" id="txtMobileNoId" size="26" value="<?php echo $mobileno; ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">State :
</td>
<td id="namefields"><select name="selectState" style="width:239px;">
<option value="0">--- Select State ---</option>
<?php
$state=mysql_query("select * from tbl_state");
while($data=mysql_fetch_array($state))
{
$state_id=$data['state_id'];
$state_name=$data['state_name'];
?>
<option value="<?Php echo $state_id; ?>" <?php if($stateid==$state_id)echo 'selected' ?>><?Php echo $state_name; ?>
</option>
<?php } ?>
</select>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">City :
</td>
<td id="namefields"><select name="selectCity" style="width:239px;">
<option value="0">---- Select City ----</option>
<?php
$city=mysql_query("select * from tbl_city");
while($data=mysql_fetch_array($city))
{
$city_id=$data['city_id'];
$city_name=$data['city_name'];
?>
<option value="<?Php echo $city_id; ?>" <?php if($cityid==$city_id) echo 'selected'?>><?Php echo $city_name; ?>
</option>
<?php } ?>
</select>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">Country :
</td>
<td id="namefields"><input type="text" name="txtCountry" id="txtCountryId" size="35" value="<?php echo $country; ?>" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td id="namelabel">
</td>
<td id="namefields"><input type="submit" name="btnEdit" value="Edit" />
</td>
<td id="sideborder">
</td>
</tr>
<tr>
<td id="sideborder">
</td>
<td>
</td>
<td>
</td>
<td id="sideborder">
</td>
</tr>
</table>
</div>
</form>
</tr>
<tr>
<td id="regileftcornbot">
</td>
<td id="regilowerstrip">
</td>
<td id="regirightcornbot">
</td>
</tr>
</table>
</div>
</body>
</html>