i want to create a login page, display the data from database of particular user in table form upto 4 columns and 1 row and also should be able to update the table data's and then logout. can anyone help me in this with a script. i need it to be done using php, mysql. i have tried till this, but i don't know what to do beyond this.
<html>
<form action="login.php" method="post">
Username: <input type="text" name="username"><p>
Password: <input type="password" name="password"><p>
<input type="submit" value="Log in!" >
</form>
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("localhost", "root", "") or die("Couldn't connect to the database!");
mysql_select_db("login") or die("Couldn't find database");
$query = mysql_query("SELECT * FROM users WHERE username='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!==0)
{
while($row = mysql_fetch_assoc($query))
{
$dbusername = $row['username'];
$dbpassword = $row['password']; # code...
}
if ($username==$dbusername&&$password==$dbpassword)
{
echo "You are logged in!";#
@$_SESSION['usernme'] = $username;
}
else
echo "Your password is incorrect!";
# code...
}
else
die("That user doesn't exists!");
}
else
die("Please enter a username and password!")
?>