Simple Project(part-3d)

editMyprofile.php





<?php
include("connect.php");

// get value of id that sent from address bar
$id=$_REQUEST['id'];



// retrive data from database
$query=mysql_query("select * from create_profile where id='$id'");
$dataPacket=mysql_fetch_array($query);

?>


<form name="userUpdateProfile" method="post"
action="editProfile_action.php">
<center>
<div ><h3>Create Profile</h3>
<div>Name:
<input name="userName" type="text" value="<?php echo $dataPacket['userName']; ?>"id="Name"/>*
</div>

</br>
<div>Father's Name:
<input name="userfatherName" type="text"
value="<?php echo $dataPacket['userfatherName'];?>" id="fatherName">*
</div>

</br>
<div>Occupation:
<input name="userOccupation" type="text"
value="<?php echo $dataPacket['userOccupation']; ?>"
id="Occupation">*
</div>

</br>
<div>Nationality:
<input name="userNationality" type="text"
value="<?php echo $dataPacket['userNationality']; ?>"
id="Nationality">*
</div>
</br>
<div>Religion:
<input name="userReligion"
type="text" value="<?php echo $dataPacket['userReligion']; ?>" id="Religion">*
</div>
</br>

<div>Address:
<textarea rows="10" cols="35" name="userAddress">
</textarea>
</div>
</br>
<div>Designation:
<input name="userDesignation" type="text"
value="<?php echo $dataPacket['userDesignation']; ?>"
id="Designation">*
</div>
</br>
<div>Country:
<?php $query="SELECT COUNTRY_ID, COUNTRY
from countrys where ISACTIVE=1 ORDER BY COUNTRY";
$result=mysql_query($query);

?>

<select name="country" >

<option value="" >Select a country</option>
<?php
while($country =mysql_fetch_array($result))
{
?>
<option value="<?php echo $country['COUNTRY_ID'];?>" <?php if($country['COUNTRY_ID']==$dataPacket['country'])
echo 'selected';?> > <?php echo $country['COUNTRY'];?></option>
<?php
}
?>
</select>

</br>
</br>
<input name="id" type="hidden" id="id" value="<?php echo $dataPacket['id']; ?>">
<input name="update" type="submit" value="update"/>
<input name="Reset" type="Reset" value="Reset"/>
<input name="Cancel" type="button" value="Cancel"/>
</div>

</div>

</center>
</form>




editProfile_action.php



<?php
include("connect.php");
session_start();
//..........................................Variable default section.........................................................

$userName=$_REQUEST['userName'];
$userfatherName =$_REQUEST['userfatherName'];
$userOccupation =$_REQUEST['userOccupation'];
$userNationality =$_REQUEST['userNationality'];
$userReligion=$_REQUEST['userReligion'];
$userAddress=$_REQUEST['userAddress'];
$userDesignation =$_REQUEST['userDesignation'];
$Country=$_REQUEST['country'];
$id=$_REQUEST['id'];



//............................................Update data........................................................................

$query=" Update create_profile set

userName='$userName',
userfatherName='$userfatherName',
userOccupation='$userOccupation',
userNationality='$userNationality',
userReligion='$userReligion',
userAddress='$userAddress',
userDesignation='$userDesignation',
country='$Country' WHERE id=".$id





;
$result=mysql_query($query);
if($result)
{
echo "Ur Profile is updated";
echo "</br>";
?>
<script language="javascript">
window.location="viewMyProfile.php?id=<?php echo $id;?>";
</script>

<?php
}


?>

Simple Project(part 3c)

.....................................................................................

This code is for displaying the profile after insertion.


.....................................................................................



viewMyProfile.php:




<?php
session_start();
?>


<table cellpadding="0" cellspacing="0" bgcolor="#FFDFFF" width="900px;">

<tr>




<?php
include("connect.php");




echo $query="select * from create_profile where userid='{$_SESSION['id']}'";
$result=mysql_query($query);
$dataPacket =mysql_fetch_array($result);



?>


</tr>


</table>
<table cellpadding="3" cellspacing="3" bgcolor="#C9C9C9" width="900px;">
<tr>
<td colspan="4" rowspan="2" valign="middle" height="50px" align="left" style=" font-family:Verdana, Geneva, sans-serif; font-weight:bold; font-size:14px; margin-left:70px; ">My Profile</td>
</tr>
<tr>
<td align="right" style=" font-family:Verdana, Geneva, sans-serif; font-weight:bold; font-size:14px; margin-left:70px; "><a href="editProfile.php?id=<?php echo $dataPacket['id']; ?>">Edit Profile</a></td>
</tr>
<caption style="background-color: #999; color: #FFF; font-size:14px; font-weight:bold;"> Congratulations ! Ur profile is created.</caption>

<tr>
<th width="35%">Name:</th>
<td><?php echo $dataPacket['userName']; ?></td>

</tr>
<tr>
<th>Father's Name:</th>
<td><?php echo $dataPacket['userfatherName']; ?></td>
</tr>
<tr>
<th>Occupation:</th>
<td><?php echo $dataPacket['userOccupation']; ?></td>
</tr>
<tr>
<th>Nationality:</th>
<td><?php echo $dataPacket['userNationality']; ?></td>
</tr>
<tr>
<th>Religion:</th>
<td><?php echo $dataPacket['userReligion']; ?></td>
</tr>
<tr>
<th>Address:</th>
<td><?php echo nl2br($dataPacket['userAddress']); ?></td>
</tr>
<tr>
<th>Designation:</th>
<td><?php echo $dataPacket['userDesignation']; ?></td>
</tr>
<tr>
<th>Country:</th>
<td><?php echo countryName($dataPacket['country']); ?></td>
</tr>


</table>
<?php
function countryName($id)
{
$query="select COUNTRY from countrys where COUNTRY_ID='$id'";
$res=mysql_query($query);
$result=mysql_fetch_array($res);
$result=$result['COUNTRY'];
return $result;
}

?>

Simple Project(part-3b)

.......................................................................................

In this section i create a page for creation for user profile .

.......................................................................................


profile.php



<script language="javascript">
function displayDiv(id)
{
document.getElementById(id).style.display='';
}
function hideDiv()
{
document.getElementById("pofile").style.display='none';
}

</script>

<?php
include("connect.php");
if(isset ($error) && $error==true)

{
?>
<center>
<div style="border:1px solid #F00; background-color:#FFF2FF; width:300px;">
<?php
echo $errorMessage;
?>
</div>
</center>
<?php
}

?>

<?php if(isProfileCreated()==1)
{

?>
<script language="javascript">
window.location="viewMyProfile.php";
</script>
<?php
}

else
{

?>

<a href="javascript:displayDiv('pofile')">Create Profile</a>


<link type="text/css" rel="stylesheet" href="style.css"/>
<div id="pofile" <?php if(!$error) {?> style="display:none;" <?php }?>>
<form name="userCreateProfile" method="post" action="profile_action.php">
<center>
<div ><h3>Create Profile</h3>
<div>Name:
<input name="userName" type="text" value="<?php if(isset($_POST['userName'])) echo $_POST['userName']; ?>"id="Name">*
</div>

</br>
<div>Father's Name:
<input name="userfatherName" type="text" value="<?php if(isset($_POST['userfatherName'])) echo $_POST['userfatherName'];?>" id="fatherName">*
</div>

</br>
<div>Occupation:
<input name="userOccupation" type="text" value="<?php if(isset($_POST['userOccupation'])) echo $_POST['userOccupation']; ?>" id="Occupation">*
</div>

</br>
<div>Nationality:
<input name="userNationality" type="text" value="<?php if(isset($_POST['userNationality'])) echo $_POST['userNationality']; ?>" id="Nationality">*
</div>
</br>
<div>Religion:
<input name="userReligion" type="text" value="<?php if(isset($_POST['userReligion'])) echo $_POST['userReligion']; ?>" id="Religion">*
</div>
</br>

<div>Address:
<textarea rows="10" cols="35" name="userAddress">
</textarea>
</div>
</br>
<div>Designation:
<input name="userDesignation" type="text" value="<?php if(isset($_POST['userDesignation'])) echo $_POST['userDesignation']; ?>" id="Designation">*
</div>
</br>
<div>Country:
<?php $query="SELECT COUNTRY_ID, COUNTRY from countrys where ISACTIVE=1 ORDER BY COUNTRY";
$result=mysql_query($query);

?>

<select name="country" >
<option value="" >Select a country</option>
<?php while($country =mysql_fetch_array($result))
{
?>
<option value="<?php echo $country['COUNTRY_ID'];?>" <?php if($country['COUNTRY_ID']==$_REQUEST['country']) echo 'selected';?> > <?php echo $country['COUNTRY'];?></option>
<?php
}
?>
</select>

</br>
</br>
<input name="Create" type="submit" value="Create"/><input name="Reset" type="Reset" value="Reset"/>
<input name="Cancel" onClick="hideDiv()" type="button" value="Cancel"/>
</div>

</div>

</center>
</form>

</div>
<div id="gallery" style="display:none;">Gallery</div>
<?php
}
function isProfileCreated()
{
$query="select userName from create_profile where userid='{$_SESSION['id']}'";
$result=mysql_query($query);
$val= mysql_num_rows($result);

return $val;
}

?>

..........................................................................................................................................................................

profile_action.php



<?php
session_start();
include("connect.php");

//..........................get values from from.........................................................//

$userName=$_REQUEST['userName'];
$userfatherName = $_REQUEST['userfatherName'];
$userOccupation = $_REQUEST['userOccupation'];
$userNationality = $_REQUEST['userNationality'];
$userReligion = $_REQUEST['userReligion'];
$userAddress = $_REQUEST['userAddress'];
$userDesignation = $_REQUEST['userDesignation'];
$Country=$_REQUEST['country'];

// .......................Error Message................................

$error=false;
$errorMessage="";

if(empty($userName))
{
$error=true;
$userNameError=true;
$errorMessage.="Please provide username.</br>";
}
if(empty($userfatherName))
{
$error=true;
$userfatherNameError=true;
$errorMessage.="Please provide Father's name.</br>";
}
if(empty($userNationality))
{
$error=true;
$userNationalityError=true;
$errorMessage.="Please provide Nationality.</br>";
}
if(empty($userReligion ))
{
$error=true;
$userReligionNameError=true;
$errorMessage.="Please provide Religion.</br>";
}
if(empty($userDesignation))
{
$error=true;
$userDesignationNameError=true;
$errorMessage.="Please provide Designation.</br>";
}
/*if(empty($country))
{
$error=true;
$countryError=true;
$errorMessage.="Please select country</br>";
}*/

//..........................insert data .........................................................//
if($error)

{

include("profile.php");
}
else
{
$sql="
INSERT into create_profile
(
userid,
userName,
userfatherName,
userOccupation,
userNationality,
userReligion,
userAddress,
userDesignation,
country
)
values

('$_SESSION[id]','$userName','$userfatherName','$userOccupation','$userNationality','$userReligion','$userAddress','$userDesignation','$Country')

";
$result=mysql_query($sql);
$id=mysql_insert_id();
if($result)
{


?>
<script language="javascript">
window.location="viewMyProfile.php?id=<?php echo $id;?>";
</script>
<?php
}

}
?>

Simple Project(Part-3a)

.......................................................................................

In this section i will try to create some functions for logged user.Here first one is create profile.It's badly need to create two table(country,create_profile).
.......................................................................................

1.CREATE TABLE `create_profile` (
`id` int(10) NOT NULL auto_increment,
`userid` int(11) NOT NULL,
`userName` varchar(255) NOT NULL,
`userfatherName` varchar(255) NOT NULL,
`userOccupation` varchar(255) NOT NULL,
`userNationality` varchar(255) NOT NULL,
`userReligion` varchar(255) NOT NULL,
`userAddress` varchar(255) NOT NULL,
`userDesignation` varchar(255) NOT NULL,
`country` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;



2.CREATE TABLE `countrys` (
`COUNTRY_ID` int(11) NOT NULL auto_increment,
`COUNTRY` varchar(100) collate utf8_unicode_ci default NULL,
`ISO3166CODE` varchar(2) collate utf8_unicode_ci default NULL,
`CONTINENT_ID` int(10) default NULL,
`ISACTIVE` tinyint(1) NOT NULL default '1',
`USER_ID_INSERTED` int(10) default NULL,
`USER_ID_UPDATED` int(10) default NULL,
`DATE_INSERTED` datetime default NULL,
`DATE_UPDATED` datetime default NULL,
PRIMARY KEY (`COUNTRY_ID`),
KEY `FK_COUNTRY_CONTINENT` (`CONTINENT_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=245 ;

--
-- Dumping data for table `countrys`
--

INSERT INTO `countrys` (`COUNTRY_ID`, `COUNTRY`, `ISO3166CODE`, `CONTINENT_ID`, `ISACTIVE`, `USER_ID_INSERTED`, `USER_ID_UPDATED`, `DATE_INSERTED`, `DATE_UPDATED`) VALUES
(1, 'Bangladesh', 'BD', 1, 1, 0, 3, '2010-02-06 08:02:57', '2010-06-16 15:06:26'),
(2, 'India', 'IN', 1, 1, 0, 5, '2010-02-06 09:02:09', '2010-02-08 12:02:11'),
(4, 'Afghanistan', 'AF', 1, 1, 0, 91, '2010-02-06 09:02:20', '2010-04-23 10:04:43'),
(5, 'Armenia', 'AM', 1, 1, 0, 91, '2010-02-06 09:02:13', '2010-04-23 10:04:02'),
(6, 'Azerbaijan', 'AZ', 1, 1, 0, 91, '2010-02-06 09:02:04', '2010-04-23 10:04:28'),
(7, 'Brunei', 'BN', 1, 1, 0, 91, '2010-02-06 09:02:22', '2010-04-23 10:04:12'),
(8, 'Bhutan', 'BT', 1, 1, 0, 91, '2010-02-06 09:02:42', '2010-04-23 10:04:25'),
(9, 'Cambodia', 'KH', 1, 1, 0, 91, '2010-02-06 09:02:14', '2010-04-23 10:04:43'),
(10, 'Indonesia', 'ID', 1, 1, 0, 91, '2010-02-06 09:02:31', '2010-04-23 10:04:59'),
(12, 'Malaysia', 'MY', 1, 1, 0, 91, '2010-02-06 09:02:05', '2010-04-23 10:04:54'),
(13, 'Maldives', 'MV', 1, 1, 0, 91, '2010-02-06 09:02:29', '2010-04-23 10:04:07'),
(14, 'Myanmar', 'MM', 1, 1, 0, 91, '2010-02-06 09:02:50', '2010-04-23 10:04:20'),
(15, 'Nepal', 'NP', 1, 1, 0, 91, '2010-02-06 09:02:06', '2010-04-23 10:04:33'),
(16, 'Pakistan', 'PK', 1, 1, 0, 91, '2010-02-06 09:02:19', '2010-04-23 10:04:47'),
(17, 'Papua New Guinea', 'PG', 1, 1, 0, 91, '2010-02-06 09:02:35', '2010-04-23 10:04:02'),
(18, 'Philippines', 'PH', 1, 1, 0, 91, '2010-02-06 09:02:48', '2010-04-23 10:04:15'),
(19, 'Singapore', 'SG', 1, 1, 0, 91, '2010-02-06 09:02:01', '2010-04-23 10:04:37'),
(20, 'Sri Lanka', 'LK', 1, 1, 0, 91, '2010-02-06 09:02:18', '2010-04-23 10:04:54'),
(21, 'Thailand', 'TH', 1, 1, 0, 91, '2010-02-06 09:02:30', '2010-04-23 10:04:08'),
(22, 'Vietnam', 'VN', 1, 1, 0, 91, '2010-02-06 09:02:46', '2010-04-23 10:04:27'),
(23, 'Kazakhstan', 'KZ', 1, 1, 0, 91, '2010-02-06 09:02:15', '2010-04-23 10:04:46'),
(24, 'Kyrgyzstan', 'KG', 1, 1, 0, 91, '2010-02-06 09:02:27', '2010-04-23 10:04:14'),
(25, 'Turkmenistan', 'TM', 1, 1, 0, 91, '2010-02-06 09:02:21', '2010-04-23 10:04:37'),
(26, 'Uzbekistan', 'UZ', 1, 1, 0, 91, '2010-02-06 09:02:34', '2010-04-23 10:04:53'),
(27, 'China', 'CN', 1, 1, 0, 91, '2010-02-06 09:02:46', '2010-04-23 10:04:17'),
(28, 'Japan', 'JP', 1, 1, 0, 91, '2010-02-06 09:02:22', '2010-04-23 10:04:36'),
(29, 'North Korea', 'KP', 1, 1, 0, 91, '2010-02-06 09:02:37', '2010-04-23 10:04:07'),
(30, 'South Korea', 'KR', 1, 1, 0, 91, '2010-02-06 09:02:52', '2010-04-23 10:04:57'),
(31, 'Mongolia', 'MN', 1, 1, 0, 91, '2010-02-06 09:02:04', '2010-04-23 10:04:13'),
(32, 'Taiwan', 'TW', 1, 1, 0, 91, '2010-02-06 09:02:17', '2010-04-23 10:04:40'),
(33, 'Bahrain', 'BH', 1, 1, 0, 91, '2010-02-06 09:02:02', '2010-04-23 10:04:58'),
(34, 'Georgia', 'GE', 1, 1, 0, 91, '2010-02-06 09:02:14', '2010-04-23 10:04:15'),
(35, 'Iran', 'IR', 1, 1, 0, 91, '2010-02-06 09:02:24', '2010-04-23 10:04:34'),
(36, 'Iraq', 'IQ', 1, 1, 0, 91, '2010-02-06 09:02:41', '2010-04-23 10:04:47'),
(37, 'Israel', 'IL', 1, 1, 0, 91, '2010-02-06 09:02:52', '2010-04-23 10:04:02'),
(38, 'Jordan', 'JO', 1, 1, 0, 91, '2010-02-06 09:02:03', '2010-04-23 10:04:18'),
(39, 'Kuwait', 'KW', 1, 1, 0, 91, '2010-02-06 09:02:16', '2010-04-23 10:04:36'),
(40, 'Lebanon', 'LB', 1, 1, 0, 91, '2010-02-06 09:02:27', '2010-04-23 10:04:53'),
(41, 'Oman', 'OM', 1, 1, 0, 91, '2010-02-06 09:02:37', '2010-04-23 10:04:16'),
(42, 'Qatar', 'QA', 1, 1, 0, 91, '2010-02-06 09:02:52', '2010-04-23 10:04:35'),
(43, 'Saudi Arabia', 'SA', 1, 1, 0, 91, '2010-02-06 09:02:06', '2010-04-23 10:04:08'),
(44, 'Syria', 'SY', 1, 1, 0, 91, '2010-02-06 09:02:20', '2010-04-23 10:04:55'),
(45, 'U.A.E.', 'AE', 1, 1, 0, 91, '2010-02-06 09:02:36', '2010-04-23 10:04:27'),
(46, 'Yemen', 'YE', 1, 1, 0, 91, '2010-02-06 09:02:08', '2010-04-23 10:04:43'),
(47, 'Albania', 'AL', 4, 1, 0, 91, '2010-02-06 09:02:45', '2010-04-23 10:04:02'),
(48, 'Andorra', 'AD', 4, 1, 0, 91, '2010-02-06 10:02:22', '2010-04-23 10:04:21'),
(49, 'Austria', 'AT', 4, 1, 0, 91, '2010-02-06 10:02:05', '2010-04-23 10:04:35'),
(50, 'Belgium', 'BE', 4, 1, 0, 91, '2010-02-06 10:02:33', '2010-04-23 10:04:53'),
(51, 'Bulgaria', 'BG', 4, 1, 0, 5, '2010-02-06 10:02:55', '2010-04-23 10:04:35'),
(52, 'Belarus', 'BY', 4, 1, 0, 5, '2010-02-06 10:02:21', '2010-04-23 10:04:54'),
(53, 'Bosnia and Herzegovina', 'BA', 4, 1, 0, 5, '2010-02-06 10:02:06', '2010-04-23 10:04:41'),
(54, 'Cyprus', 'CY', 4, 1, 0, 5, '2010-02-06 10:02:27', '2010-04-23 10:04:23'),
(55, 'Croatia', 'CR', 4, 1, 0, 5, '2010-02-06 10:02:42', '2010-04-23 10:04:09'),
(56, 'Czech Republic', 'CZ', 4, 1, 0, 5, '2010-02-06 10:02:57', '2010-04-23 10:04:52'),
(57, 'Denmark', 'DK', 4, 1, 0, 3, '2010-02-06 10:02:14', '2010-04-23 10:04:48'),
(58, 'Estonia', 'EE', 4, 1, 0, 5, '2010-02-06 10:02:43', '2010-04-23 10:04:53'),
(59, 'Finland', 'FI', 4, 1, 0, 3, '2010-02-06 10:02:08', '2010-04-23 10:04:57'),
(60, 'France', 'FR', 4, 1, 0, 3, '2010-02-06 10:02:36', '2010-04-23 10:04:34'),
(61, 'Germany', 'GE', 4, 1, 0, 3, '2010-02-06 10:02:52', '2010-04-23 10:04:32'),
(62, 'Greece', 'GR', 4, 1, 0, 3, '2010-02-06 10:02:17', '2010-04-23 10:04:37'),
(63, 'Hungary', 'HU', 4, 1, 0, 3, '2010-02-06 10:02:39', '2010-04-23 10:04:57'),
(64, 'Iceland', 'IS', 4, 1, 0, 3, '2010-02-06 10:02:56', '2010-04-23 10:04:22'),
(65, 'Ireland', 'IE', 4, 1, 0, 3, '2010-02-06 10:02:19', '2010-04-23 10:04:00'),
(66, 'Italy', 'IT', 4, 1, 0, 3, '2010-02-06 10:02:37', '2010-04-23 10:04:23'),
(67, 'Latvia', 'LV', 4, 1, 0, 3, '2010-02-06 10:02:51', '2010-04-23 10:04:50'),
(68, 'Lithuania', 'LT', 4, 1, 0, 3, '2010-02-06 10:02:22', '2010-04-23 10:04:53'),
(69, 'Luxembourg', 'LU', 4, 1, 0, 3, '2010-02-06 10:02:35', '2010-04-23 10:04:29'),
(70, 'Liechtenstein', 'LI', 4, 1, 0, 3, '2010-02-06 10:02:56', '2010-04-23 10:04:00'),
(71, 'Malta', 'MT', 4, 1, 0, 3, '2010-02-06 10:02:11', '2010-04-23 10:04:13'),
(72, 'Moldova', 'MD', 4, 1, 0, 3, '2010-02-06 10:02:37', '2010-04-23 10:04:44'),
(73, 'Monaco', 'MC', 4, 1, 0, 3, '2010-02-06 10:02:01', '2010-04-23 10:04:13'),
(74, 'Montenegro', 'ME', 4, 1, 0, 3, '2010-02-06 10:02:17', '2010-04-23 10:04:45'),
(75, 'Netherlands', 'NL', 4, 1, 0, 3, '2010-02-06 10:02:38', '2010-04-23 10:04:02'),
(76, 'Norway', 'NO', 4, 1, 0, 3, '2010-02-06 10:02:51', '2010-04-23 10:04:30'),
(77, 'Poland', 'PL', 4, 1, 0, 3, '2010-02-06 10:02:09', '2010-04-23 10:04:05'),
(78, 'Portugal', 'PT', 4, 1, 0, 3, '2010-02-06 10:02:25', '2010-04-23 10:04:37'),
(79, 'Romania', 'RO', 4, 1, 0, 3, '2010-02-06 10:02:43', '2010-04-23 10:04:14'),
(80, 'Russia', 'RU', 4, 1, 0, 3, '2010-02-06 10:02:30', '2010-04-23 10:04:52'),
(82, 'Serbia', 'RS', 4, 1, 0, 3, '2010-02-06 10:02:00', '2010-04-23 10:04:20'),
(84, 'Slovenia', 'SI', 4, 1, 0, 3, '2010-02-06 10:02:29', '2010-04-23 10:04:42'),
(85, 'Spain', 'ES', 4, 1, 0, 3, '2010-02-06 10:02:43', '2010-04-23 10:04:15'),
(86, 'Sweden', 'SE', 4, 1, 0, 3, '2010-02-06 10:02:58', '2010-04-23 10:04:01'),
(87, 'Switzerland', 'CH', 4, 1, 0, 3, '2010-02-06 10:02:14', '2010-04-23 10:04:25'),
(88, 'Turkey', 'TR', 4, 1, 0, 3, '2010-02-06 10:02:38', '2010-04-23 10:04:01'),
(89, 'Ukraine', 'UA', 4, 1, 0, 3, '2010-02-06 10:02:01', '2010-04-23 10:04:36'),
(90, 'United Kingdom', 'GB', 4, 1, 0, 3, '2010-02-06 10:02:18', '2010-04-23 10:04:11'),
(91, 'Vatican City State', 'VA', 4, 1, 0, 5, '2010-02-06 10:02:46', '2010-04-23 11:04:06'),
(92, 'Antigua and Barbuda', 'AG', 2, 1, 0, 3, '2010-02-06 10:02:58', '2010-04-23 10:04:10'),
(93, 'Bahamas', 'BS', 2, 1, 0, 3, '2010-02-06 10:02:19', '2010-04-23 10:04:44'),
(95, 'Belize', 'BZ', 2, 1, 0, 3, '2010-02-06 10:02:33', '2010-04-23 10:04:22'),
(96, 'Canada', 'CA', 2, 1, 0, 3, '2010-02-06 10:02:55', '2010-04-23 10:04:18'),
(97, 'Costa Rica', 'CR', 2, 1, 0, 3, '2010-02-06 10:02:12', '2010-04-23 10:04:43'),
(98, 'Cuba', 'CU', 2, 1, 0, 3, '2010-02-06 10:02:53', '2010-04-23 10:04:51'),
(99, 'Dominica', 'DM', 2, 1, 0, 3, '2010-02-06 10:02:08', '2010-04-23 10:04:26'),
(100, 'Dominican- Republic', 'DO', 2, 1, 0, 5, '2010-02-06 10:02:31', '2010-04-23 10:04:18'),
(101, 'El Salvador', 'SV', 2, 1, 0, 5, '2010-02-06 10:02:00', '2010-04-23 10:04:42'),
(102, 'Greenland', 'GL', 2, 1, 0, 3, '2010-02-06 10:02:21', '2010-07-02 11:07:59'),
(103, 'Grenada', 'GD', 2, 1, 0, 5, '2010-02-06 10:02:34', '2010-04-23 10:04:28'),
(104, 'United States', 'US', 2, 1, 0, 3, '2010-02-06 10:02:48', '2010-06-24 15:06:39'),
(105, 'Trinidad and Tobago', 'TT', 2, 1, 0, 5, '2010-02-06 10:02:12', '2010-04-23 10:04:49'),
(106, 'Saint Vincent and the Grenadines', 'VC', 2, 1, 0, 5, '2010-02-06 10:02:29', '2010-04-23 11:04:50'),
(107, 'Panama', 'PA', 2, 1, 0, 5, '2010-02-06 10:02:49', '2010-04-23 11:04:49'),
(108, 'Mexico', 'MX', 2, 1, 0, 5, '2010-02-06 10:02:04', '2010-04-23 10:04:22'),
(109, 'Jamaica', 'JM', 2, 1, 0, 5, '2010-02-06 10:02:31', '2010-04-23 11:04:07'),
(110, 'Haiti', 'HT', 2, 1, 0, 5, '2010-02-06 10:02:02', '2010-04-23 11:04:38'),
(111, 'Honduras', 'HN', 2, 1, 0, 5, '2010-02-06 10:02:22', '2010-04-23 11:04:13'),
(112, 'Guatemala', 'GT', 2, 1, 0, 5, '2010-02-06 10:02:35', '2010-04-23 10:04:28'),
(113, 'Argentina', 'AR', 3, 1, 0, 5, '2010-02-06 10:02:42', '2010-04-23 10:04:09'),
(114, 'Bolivia', 'BO', 3, 1, 0, 5, '2010-02-06 10:02:49', '2010-04-23 11:04:44'),
(115, 'Brazil', 'BR', 3, 1, 0, 5, '2010-02-06 10:02:04', '2010-04-23 10:04:39'),
(116, 'Chile', 'CL', 3, 1, 0, 5, '2010-02-06 10:02:17', '2010-04-23 10:04:15'),
(117, 'Colombia', 'CO', 3, 1, 0, 5, '2010-02-06 10:02:32', '2010-04-23 10:04:45'),
(118, 'Ecuador', 'EC', 3, 1, 0, 5, '2010-02-06 10:02:47', '2010-04-23 10:04:58'),
(119, 'Guyana', 'GY', 3, 1, 0, 5, '2010-02-06 10:02:01', '2010-04-23 10:04:36'),
(120, 'Paraguay', 'PY', 3, 1, 0, 5, '2010-02-06 10:02:21', '2010-04-23 10:04:11'),
(121, 'Peru', 'PE', 3, 1, 0, 5, '2010-02-06 10:02:33', '2010-04-23 10:04:46'),
(122, 'Uruguay', 'UY', 3, 1, 0, 5, '2010-02-06 10:02:11', '2010-04-23 10:04:25'),
(123, 'Venezuela', 'VE', 3, 1, 0, 5, '2010-02-06 10:02:28', '2010-04-23 10:04:53'),
(124, 'Australia', 'AU', 6, 1, 0, 5, '2010-02-06 10:02:20', '2010-04-23 10:04:13'),
(125, 'Fiji', 'FJ', 6, 1, 0, 5, '2010-02-06 10:02:47', '2010-04-23 10:04:01'),
(126, 'New Zealand', 'NZ', 6, 1, 0, 5, '2010-02-06 10:02:57', '2010-04-23 10:04:24'),
(127, 'Solomon Islands', 'SB', 6, 1, 0, 5, '2010-02-06 10:02:10', '2010-04-23 10:04:07'),
(128, 'Algeria', 'DZ', 5, 1, 0, 5, '2010-02-06 10:02:48', '2010-04-23 10:04:35'),
(129, 'Chad', 'TD', 5, 1, 0, 5, '2010-02-06 10:02:28', '2010-04-23 10:04:01'),
(130, 'Congo', 'CG', 5, 1, 0, 5, '2010-02-06 10:02:48', '2010-04-23 10:04:43'),
(131, 'Egypt', 'EG', 5, 1, 0, 5, '2010-02-06 10:02:06', '2010-04-23 10:04:13'),
(132, 'Ethiopia', 'ET', 5, 1, 0, 5, '2010-02-06 10:02:33', '2010-04-23 10:04:52'),
(133, 'Gambia', 'GM', 5, 1, 0, 5, '2010-02-06 10:02:57', '2010-04-23 10:04:28'),
(134, 'Ghana', 'GH', 5, 1, 0, 5, '2010-02-06 10:02:11', '2010-04-23 10:04:50'),
(135, 'Kenya', 'KE', 5, 1, 0, 5, '2010-02-06 10:02:11', '2010-04-23 10:04:39'),
(136, 'Liberia', 'LR', 5, 1, 0, 5, '2010-02-06 10:02:43', '2010-04-23 10:04:14'),
(137, 'Libya', 'LY', 5, 1, 0, 5, '2010-02-06 11:02:35', '2010-04-23 10:04:56'),
(138, 'Nigeria', 'NG', 5, 1, 0, 5, '2010-02-06 11:02:30', '2010-04-23 10:04:58'),
(139, 'Senegal', 'SN', 5, 1, 0, 5, '2010-02-06 11:02:12', '2010-04-23 10:04:19'),
(140, 'South Africa', 'ZA', 5, 1, 0, 5, '2010-02-06 11:02:14', '2010-04-23 10:04:50'),
(141, 'Sudan', 'SD', 5, 1, 0, 5, '2010-02-06 11:02:39', '2010-04-23 10:04:18'),
(142, 'Tanzania', 'TZ', 5, 1, 0, 5, '2010-02-06 11:02:04', '2010-04-23 10:04:00'),
(143, 'Togo', 'TG', 5, 1, 0, 5, '2010-02-06 11:02:26', '2010-04-23 10:04:18'),
(144, 'Western Sahara', 'EH', 5, 1, 0, 5, '2010-02-06 11:02:42', '2010-04-23 10:04:57'),
(145, 'Uganda', 'UG', 5, 1, 0, 5, '2010-02-06 11:02:08', '2010-04-23 10:04:29'),
(146, 'Zimbabwe', 'ZW', 5, 1, 0, 5, '2010-02-06 11:02:26', '2010-04-23 10:04:07'),
(147, 'Morocco', 'MA', 5, 1, 5, 5, '2010-02-09 06:02:10', '2010-04-23 10:04:26'),
(148, 'Palestine', 'PS', 1, 1, 5, 5, '2010-02-09 07:02:41', '2010-04-23 10:04:50'),
(149, 'CAMEROON', 'CM', 5, 1, 3, 3, '2010-06-16 16:06:42', '2010-07-02 11:07:54'),
(150, 'HONG KONG', 'HK', 1, 1, 3, NULL, '2010-06-29 10:06:09', NULL),
(151, 'JERSEY', 'JE', 4, 1, 3, NULL, '2010-07-02 14:07:28', NULL),
(152, 'KIRIBATI', 'KI', 6, 1, 3, NULL, '2010-07-02 14:07:39', NULL),
(153, 'LESOTHO', 'LS', 5, 1, 3, NULL, '2010-07-02 14:07:20', NULL),
(154, 'MACAO', 'MO', 1, 1, 3, NULL, '2010-07-02 14:07:07', NULL),
(155, 'ANGOLA', 'AO', 5, 1, 3, NULL, '2010-07-02 14:07:08', NULL),
(156, 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'MK', 4, 1, 3, NULL, '2010-07-02 14:07:25', NULL),
(157, 'MADAGASCAR', 'MG', 5, 1, 3, NULL, '2010-07-02 14:07:12', NULL),
(158, 'MALAWI', 'MW', 5, 1, 3, NULL, '2010-07-02 14:07:01', NULL),
(159, 'MALI', 'ML', 5, 1, 3, NULL, '2010-07-02 14:07:34', NULL),
(160, 'BENIN', 'BJ', 5, 1, 3, NULL, '2010-07-02 14:07:44', NULL),
(161, 'MARSHALL ISLANDS', 'MH', 6, 1, 3, NULL, '2010-07-02 14:07:16', NULL),
(162, 'BERMUDA', 'BM', 2, 1, 3, NULL, '2010-07-02 14:07:37', NULL),
(163, 'MARTINIQUE', 'MQ', 3, 1, 3, NULL, '2010-07-02 14:07:00', NULL),
(164, 'MAURITANIA', 'MR', 5, 1, 3, NULL, '2010-07-02 14:07:09', NULL),
(165, 'BOTSWANA', 'BW', 5, 1, 3, NULL, '2010-07-02 14:07:28', NULL),
(166, 'MAURITIUS', 'MU', 5, 1, 3, NULL, '2010-07-02 14:07:55', NULL),
(167, 'MAYOTTE', 'YT', 5, 1, 3, NULL, '2010-07-02 14:07:24', NULL),
(168, 'BRITISH INDIAN OCEAN TERRITORY', 'AO', 1, 1, 3, NULL, '2010-07-02 14:07:05', NULL),
(169, 'MICRONESIA, FEDERATED STATES OF', 'FM', 6, 1, 3, NULL, '2010-07-02 14:07:04', NULL),
(170, 'BURKINA FASO', 'BF', 5, 1, 3, NULL, '2010-07-02 14:07:24', NULL),
(171, 'BURUNDI', 'BI', 5, 1, 3, NULL, '2010-07-02 14:07:40', NULL),
(172, 'MONTSERRAT', 'MS', 3, 1, 3, NULL, '2010-07-02 14:07:50', NULL),
(173, 'CAPE VERDE', 'CV', 5, 1, 3, NULL, '2010-07-02 14:07:05', NULL),
(174, 'MOZAMBIQUE', 'MZ', 5, 1, 3, NULL, '2010-07-02 14:07:37', NULL),
(175, 'NAMIBIA', 'NA', 5, 1, 3, NULL, '2010-07-02 14:07:18', NULL),
(176, 'CAYMAN ISLANDS', 'KY', 2, 1, 3, NULL, '2010-07-02 14:07:54', NULL),
(177, 'NAURU', 'NR', 6, 1, 3, NULL, '2010-07-02 14:07:30', NULL),
(178, 'NETHERLANDS ANTILLES', 'AN', 2, 1, 3, NULL, '2010-07-02 14:07:40', NULL),
(179, 'CENTRAL AFRICAN REPUBLIC', 'CF', 5, 1, 3, NULL, '2010-07-02 14:07:22', NULL),
(180, 'ANTARCTICA', 'AQ', 7, 1, 3, NULL, '2010-07-02 14:07:12', NULL),
(181, 'NEW CALEDONIA', 'NC', 6, 1, 3, NULL, '2010-07-02 14:07:30', NULL),
(182, 'NICARAGUA', 'NI', 2, 1, 3, NULL, '2010-07-02 14:07:07', NULL),
(183, 'NIGER', 'NE', 5, 1, 3, NULL, '2010-07-02 14:07:53', NULL),
(184, 'NIUE', 'NU', 6, 1, 3, NULL, '2010-07-02 14:07:31', NULL),
(185, 'NORFOLK ISLAND', 'NF', 6, 1, 3, NULL, '2010-07-02 14:07:03', NULL),
(186, 'NORTHERN MARIANA ISLANDS', 'MP', 6, 1, 3, NULL, '2010-07-02 15:07:42', NULL),
(187, 'PALAU', 'PW', 6, 1, 3, NULL, '2010-07-02 15:07:26', NULL),
(188, 'PITCAIRN', 'PN', 2, 1, 3, NULL, '2010-07-02 15:07:57', NULL),
(189, 'PUERTO RICO', 'PR', 2, 1, 3, NULL, '2010-07-02 15:07:49', NULL),
(190, 'ANGUILLA', 'AI', 2, 1, 3, NULL, '2010-07-02 15:07:51', NULL),
(191, 'ALAND ISLANDS', 'AX', 6, 1, 3, 3, '2010-07-02 15:07:02', '2010-07-02 15:07:21'),
(192, 'ARUBA', 'AW', 3, 1, 3, NULL, '2010-07-02 15:07:13', NULL),
(193, 'CHRISTMAS ISLAND', 'CX', 1, 1, 3, NULL, '2010-07-02 15:07:57', NULL),
(194, 'COMOROS', 'KM', 5, 1, 3, NULL, '2010-07-02 15:07:28', NULL),
(195, 'REUNION', 'RE', 5, 1, 3, NULL, '2010-07-02 15:07:22', NULL),
(196, 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'CD', 5, 1, 3, NULL, '2010-07-02 15:07:48', NULL),
(197, 'RWANDA', 'RW', 5, 1, 3, NULL, '2010-07-02 15:07:09', NULL),
(198, 'COOK ISLANDS', 'CK', 3, 1, 3, NULL, '2010-07-02 15:07:03', NULL),
(199, 'SAINT BARTHÉLEMY', 'BL', 2, 1, 3, NULL, '2010-07-02 15:07:35', NULL),
(200, 'SAINT HELENA', 'SH', 5, 1, 3, NULL, '2010-07-02 15:07:28', NULL),
(201, 'DJIBOUTI', 'DJ', 5, 1, 3, NULL, '2010-07-02 15:07:49', NULL),
(202, 'SAINT KITTS AND NEVIS', 'KN', 2, 1, 3, NULL, '2010-07-02 15:07:13', NULL),
(203, 'EQUATORIAL GUINEA', 'GQ', 6, 1, 3, NULL, '2010-07-02 15:07:35', NULL),
(204, 'COCOS (KEELING) ISLANDS', 'CC', 5, 1, 3, NULL, '2010-07-02 15:07:56', NULL),
(205, 'ERITREA', 'ER', 5, 1, 3, NULL, '2010-07-02 15:07:06', NULL),
(206, 'FALKLAND ISLANDS (MALVINAS)', 'FK', 7, 1, 3, NULL, '2010-07-02 15:07:53', NULL),
(207, 'FAROE ISLANDS', 'FO', 4, 1, 3, NULL, '2010-07-02 15:07:09', NULL),
(208, 'FRENCH GUIANA', 'GF', 3, 1, 3, NULL, '2010-07-02 15:07:46', NULL),
(209, 'FRENCH POLYNESIA', 'PF', 6, 1, 3, NULL, '2010-07-02 15:07:33', NULL),
(210, 'SAINT LUCIA', 'LC', 2, 1, 3, NULL, '2010-07-02 15:07:45', NULL),
(211, 'FRENCH SOUTHERN TERRITORIES', 'TF', 6, 1, 3, NULL, '2010-07-02 15:07:13', NULL),
(212, 'GABON', 'GA', 5, 1, 3, NULL, '2010-07-02 15:07:46', NULL),
(213, 'GIBRALTAR', 'GI', 4, 1, 3, NULL, '2010-07-02 15:07:54', NULL),
(214, 'SAINT MARTIN', 'MF', 4, 1, 3, NULL, '2010-07-02 15:07:42', NULL),
(215, 'SAINT PIERRE AND MIQUELON', 'SA', 2, 1, 3, NULL, '2010-07-02 15:07:13', NULL),
(216, 'SAMOA', 'WS', 6, 1, 3, NULL, '2010-07-02 15:07:55', NULL),
(217, 'SAN MARINO', 'SM', 4, 1, 3, NULL, '2010-07-02 15:07:36', NULL),
(218, 'SAO TOME AND PRINCIPE', 'ST', 5, 1, 3, NULL, '2010-07-02 15:07:13', NULL),
(219, 'SLOVAKIA', 'SK', 4, 1, 3, NULL, '2010-07-02 15:07:07', NULL),
(220, 'SEYCHELLES', 'SC', 5, 1, 3, NULL, '2010-07-02 15:07:21', NULL),
(221, 'SIERRA LEONE', 'SL', 5, 1, 3, NULL, '2010-07-02 15:07:31', NULL),
(222, 'SOMALIA', 'SO', 5, 1, 3, NULL, '2010-07-02 15:07:04', NULL),
(223, 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'GS', 3, 1, 3, NULL, '2010-07-02 15:07:17', NULL),
(224, 'SWAZILAND', 'SZ', 5, 1, 3, NULL, '2010-07-02 15:07:04', NULL),
(225, 'SVALBARD AND JAN MAYEN', 'SJ', 4, 1, 3, NULL, '2010-07-02 15:07:51', NULL),
(226, 'SURINAME', 'SR', 3, 1, 3, NULL, '2010-07-02 15:07:18', NULL),
(227, 'GUADELOUPE', 'GP', 2, 1, 3, NULL, '2010-07-02 15:07:14', NULL),
(228, 'GUAM', 'GU', 2, 1, 3, NULL, '2010-07-02 15:07:41', NULL),
(229, 'GUERNSEY', 'GG', 4, 1, 3, NULL, '2010-07-02 15:07:55', NULL),
(230, 'GUINEA', 'GN', 5, 1, 3, NULL, '2010-07-02 15:07:19', NULL),
(231, 'GUINEA-BISSAU', 'GW', 5, 1, 3, NULL, '2010-07-02 15:07:10', NULL),
(232, 'TAJIKISTAN', 'TJ', 1, 1, 3, NULL, '2010-07-02 15:07:16', NULL),
(233, 'TIMOR-LESTE', 'TL', 1, 1, 3, NULL, '2010-07-02 16:07:45', NULL),
(234, 'TOKELAU', 'TK', 6, 1, 3, NULL, '2010-07-02 16:07:40', NULL),
(235, 'TONGA', 'TO', 6, 1, 3, NULL, '2010-07-02 16:07:49', NULL),
(236, 'TUNISIA', 'TN', 5, 1, 3, NULL, '2010-07-02 16:07:20', NULL),
(237, 'TURKS AND CAICOS ISLANDS', 'TC', 2, 1, 3, NULL, '2010-07-02 16:07:21', NULL),
(238, 'TUVALU', 'TV', 6, 1, 3, NULL, '2010-07-02 16:07:34', NULL),
(239, 'UNITED STATES MINOR OUTLYING ISLANDS', 'UM', 6, 1, 3, NULL, '2010-07-02 16:07:45', NULL),
(240, 'VANUATU', 'VU', 6, 1, 3, NULL, '2010-07-02 16:07:01', NULL),
(241, 'VIRGIN ISLANDS, BRITISH', 'VG', 2, 1, 3, NULL, '2010-07-02 16:07:53', NULL),
(242, 'VIRGIN ISLANDS, U.S.', 'VI', 2, 1, 3, NULL, '2010-07-02 16:07:17', NULL),
(243, 'WALLIS AND FUTUNA', 'WF', 6, 1, 3, NULL, '2010-07-02 16:07:46', NULL),
(244, 'ZAMBIA', 'ZM', 5, 1, 3, NULL, '2010-07-02 16:07:16', NULL);

-- --------------------------------------------------------

Simple Project(Part 2b)

.....................................................................................

Now i will create a login page for registered user.
.....................................................................................

userLogin.php:



<?php
session_start();
echo $_SESSION['uName'];

?>

<html>
<link type="text/css" rel="stylesheet" href="style.css"/>
<body>

<form name="userlogin" method="post" action="userLogin_action.php">
<center>
<table cellpadding=4 cellspacing=2 border=0>
<th bgcolor="#CCCCFF" colspan=2>
<font size=5>USER LOGIN</font>
<br>
<font size=1><sup>*</sup> Required Fields</font>
</th>
<tr bgcolor="#c8d8f8">
<td valign=top colspan=2>
<b>User Name<sup>*</sup></b>
<input type="text" name="uName" size=20 maxlength=20>
</td>
</tr>
<tr bgcolor="#c8d8f8">
<td valign=top>
<b>Password<sup>*</sup></b>
  
<input type="password" name="userPassword1" >

</td>
<tr bgcolor="#c8d8f8">
<td align=center colspan=2>
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</center>
</form>

</body>

</html>



.....................................................................................

....................................................................................

userLogin_action.php:


<?php
include("connect.php");
session_start();

if($_SESSION['uName'])
{
?>
<div style="text-align:right;">
<a href="logout.php"> <strong>Logout</strong></a>
</a>
</div>
<?php
}




//...................... get values from from.........................................

$userName=$_REQUEST['uName'];
$userPassword1=md5($_REQUEST['userPassword1']);
$id=$_REQUEST['id'];

/// To protect MySQL injection (more detail about MySQL injection)
//$userName = stripslashes($userName);
//$userPassword1 = stripslashes ($userPassword);
//$userName = mysql_real_escape_string($userName);
//$userPassword1 = mysql_real_escape_string($userPassword1);

//...................... Database Query.........................................


$sql="SELECT * from sign_up where userName='$userName' and password='".$userPassword1."'";

$result = mysql_query($sql);

$rs = mysql_fetch_array($result);


// $rs['userName'];
// $rs['password'];



if($rs ['userName']==$userName && $rs['password']==$userPassword1)
{
$_SESSION['uName']=$userName;
$_SESSION['id']=$rs['id'];

echo " Welcome ". "<span style='color:#69F;' ><b>". $userName."</b></span>".'!'.' your login is successful. Enjoy this site. Thank you very much';
?>

<table bgcolor="#CCCCCC" width="800px;">
<tr >
<td align="left"><a href="profile.php">My Profile</a></td>

</tr>
<tr>
<td align="left"><a href="lifeStyle.php">My lifestyle</a></td>
</tr>
<tr>
<td align="left"><a href="createGallery.php">Create Gallery</a></td>
</tr>
<tr>
<td align="left"><a href="aboutMe.php">About Me</a></td>
</tr>
<tr>
<td align="left"><a href="contactMe.php">Contact Me</a></td>
</tr>
</table>


<?php

}


else

{


echo "Invalid username or Password";
}


?>

Simple Project (part-2a)

signUp.php:


<?php
if(isset($error) && $error==true )
{
?>
<center>
<div style="border:1px solid #F00; background-color:#FFF2FF; width:300px;">
<?php
echo $errorMessage;

?>
</div>
</center>
<?php
}
?>



<html>
<link type="text/css" rel="stylesheet" href="style.css"/>
<body>

<div>
<form name="userSignUp" method="post" action="signUp_action.php">
<center>
<table border="0" width="600px" cellpadding="0" cellspacing="0" >
<tr>
<td><h1>User Registration</h1></td>
</tr>
<tr>
<td>





</td>
</tr>
<tr>
<td>User Name:
<input name="userName" type="text" id="userName" value="<?php if(isset($_POST['userName'])) echo $_POST['userName']; ?>"/>*

</td>
</tr>
<br>
<tr>
<td>Email:
<input name="userEmail" type="text" id="userEmail" value="<?php if (isset($_POST['userEmail'])) echo $_POST['userEmail']; ?>"/>*

</td>

</tr>
<br>
<tr>
<td>Password:
<input type="password" name="userPassword1" value="">*

</td>

</tr>
<br>
<tr>
<td>Confirm Password:
<input type="password" name="userPassword2" value="">*

</td>

</tr>
<br>
<tr>
<td>
<input type="submit" name="submit" value="Submit"> <input type="reset"
value="Reset">

</td>

</tr>
</table>
</center>
</form>
</div>
</body>
</html>


.....................................................................................

Then i provide the form's required action.The name of page is signUp_action.php

.....................................................................................

signUp_action.php:




<?php
include("connect.php");


//.................................Variable default section...................................

$userName=$_REQUEST['userName'];
$userEmail=$_REQUEST['userEmail'];
$userPassword1=$_POST['userPassword1'];
$userPassword2=$_POST['userPassword2'];
$password=md5($userPassword1);

// .......................Email validation................................


function isValidEmail($userEmail)
{
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";

if (eregi($pattern, $userEmail))
{
return true;
}
else
{
return false;

}
}

// .......................Error Message................................

$error=false;
$errorMessage="";

if(empty($userName))
{
$error=true;
$userNameError=true;
$errorMessage.="PLease provide username.</br>";
}
if(empty($userEmail))
{
$error=true;
$userEmailError=true;
$errorMessage.="PLease provide email.</br>";
}



if($userPassword1=="")
{
$error=true;
$userPassword1Error=true;
$errorMessage.="PLease provide password.</br>";

}
/*if($userPassword1)
{
if(preg_match("/^.*(?=.{8,})(?=.*[a-z]+)(?=.*[^A-Za-z0-9])(?=.*[0-9\.\-\@\#\$\&]).*$/",$userPassword1))

{
$successMessage.= "Successfuly checked your password.U have to login now";

}
{
$error=true;
$paswordValidationError=true;
$errorMessage.= "Please Enter"."<br />"."Atleast 8 character"."<br />"."Alpha numeric value"."<br />"."1 Special character";
}
}
*/
if($userPassword1!=$userPassword2)
{
$error=true;
$passwordMatchingError=true;
$errorMessage.="Password does not match.</br>";

}


if(!isValidEmail($userEmail))
{
$error=true;
$emailValidationError=true;
$errorMessage.="Invalid email id.</br>";
}


//..............................duplicate email check.........................................................


$query = "SELECT userEmail FROM sign_up WHERE userEmail='" . $userEmail . "'";
$result=mysql_query($query);

$loginFoundEmail = mysql_num_rows($result);
if($loginFoundEmail)
{
$error=true;
$loginFoundEmailError=true;
$errorMessage.="User email is already in use.";
}


//.............................Insert Data...............................

if($error)

{

include("signUp.php");
}
else
{

$sql="insert into sign_up
(
userName,
userEmail,
password

)
values

('$userName','$userEmail','$password')
";


$result=mysql_query($sql);
if($sql)
{

$succes="Successfully inserted";
?>
<script language="javascript">
window.location="message.php";
</script>
<?php

}

}





?>




.....................................................................................

Here i create a page for message displaying after successful registration and redirects user to login page.

.....................................................................................


message.php:



<?php

session_start();
if(!session_is_registered(userName))
{
?>
<script language="javascript">
window.location="userLogin.php";
</script>
<?php
}
?>

<html>
<body>
Login Successful
</body>
</html>

Simple PHP project BY me

Here i will try to build up a simple project step by step..........................................................................................................................................................................

Step 1: Create database connection in php & table sign_up

**.................................................................................**
Create database
**.................................................................................**


CREATE TABLE `sign_up` (
`id` int(20) NOT NULL auto_increment,
`userName` varchar(50) NOT NULL,
`userEmail` varchar(50) NOT NULL,
`password` varchar(250) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=12346 ;

**...................................................................................**
connect.php
**...................................................................................**
<?php
mysql_connect("localhost", "root", "") or die ("Cannot connected database");
mysql_select_db("rakhi_database")or die ("Cannot connected db");

?>
powered by Blogger | WordPress by Newwpthemes | Converted by BloggerTheme