Simple Project(Part 2b)
.....................................................................................
Now i will create a login page for registered user.
.....................................................................................
userLogin.php:
.....................................................................................
....................................................................................
userLogin_action.php:
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";
}
?>
0 Response to "Simple Project(Part 2b)"
Post a Comment