login user

I want to login the user if the username and password in textbox matches with the dasebase and should show the details of the user and should show an error if username and password doesnot match.The problem is that i don’t know howand where to write the error message inside the coding.
my coding for login page is

</table

my coding for profile.php is

MEMBER LOGIN
User id
Password
<?php echo $error; ?>
| Forgot password | New Registration |
<?php if(isset($_REQUEST["login"])){ $username=$_POST["name1"]; $password=$_POST["pas1"]; $sql="select * from register where username='$username' && password='$password'"; $res=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($res)) { ?>
<td height="205" style="padding-left:5px; font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;"> <?php echo $row["firstname"]; ?></td>
<td style="padding-left:5px; font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;"> <?php echo $row["lastname"]; ?></td>
 <td style="padding-left:5px; font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;"> <?php echo $row["address1"]; ?><br/> <?php echo $row["address2"]; ?><br/><?php echo $row["address3"]; ?><br/><?php echo $row["zipcode"]; ?><br/><?php echo $row["state"]; ?><br/><?php echo $row["country"]; ?></td>


<td style="padding-left:5px; font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;"><?php echo $row["gender"]; ?></td>
<td style="padding-left:5px; font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;"> <?php echo $row["phone"]; ?></td>
<td style="font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;" align="center"><img width="160px" height="165px" src="images/<?php echo $row["image"]; ?>"/> </td>
<td style="font-size:14px;  font-family:Verdana, Arial, Helvetica, sans-serif;" align="center"><a  style="color:#000000; text-decoration:none" href="profileedit.php?id=<?php echo $row["id"]; ?>">edit</a></td>
<?php } }

?>

First name Last name Address Gender Phone no: Photo EDIT

There are a lot of issues with your code. First, you have Javascript validate code in it and PHP at the bottom of the page and a few layout issues. I think it would be best if you review a login page tutorial that would walk you thru how to do this. Create some new code and then come back if you have problems. Here is a great tutorial that covers all of the steps for creating a login system. It explains everything including the uses of a database for this project. I think it will help you.

http://www.phpeasystep.com/phptu/6.html

Hope that helps! Good luck and let us know how you do with it.

Sponsor our Newsletter | Privacy Policy | Terms of Service