i have create a login page and registration
how can i view table from database to php output and to change password.
heres my login.php
<?php
session_start();
$username= $_POST['username'];
$password= $_POST['password'];
$password=md5($password);
if($username&&$password)
{
$connect=mysql_connect("localhost","root","") or die("Coldn't connect");
mysql_select_db("phplogin") or die("Couldn't find db");
$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'];
}
if ($username==$dbusername&&md5($password)==$dbpassword)
{
echo "youre in <a href='member.php'>Click</a> here to enter the member page.";
$_SESSION['username']=$username;
}
else
echo "incorrect password!";
}
else
die("That user doesnt exist!");
}
else
die("Please enter username and password!");
?>
and for register.php
<?php
$submit=$_POST['submit'];
$fullname=strip_tags($_POST['fullname']);
$username=strtolower(strip_tags($_POST['username']));
$password=$_POST['password'];
$repeatpassword=$_POST['repeatpassword'];
$date=date("Y-m-d");
if ($submit)
{
$connect=mysql_connect("localhost","root","");
mysql_select_db('phplogin');
$namecheck=mysql_query("SELECT username FROM users WHERE username='$username'");
$count=mysql_num_rows($namecheck);
if($count!=0)
{
die ("Username already taken!");
}
//check for existance
if ($fullname&&$username&&$password&&$repeatpassword)
{
if ($password==$repeatpassword)
{
if (strlen($username)>25 || strlen($fullname)>25)
{
echo "your username/fullname shoudld be less than 25";
}
else
if (strlen($password)>25 || strlen($password)<6)
{
echo "your password should be between 6 and 25 character";
}
else
{
$password=md5($password);
$repeatpassword=md5($repeatpassword);
$query=mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date') ");
echo "<p>you have registered , <a href='index.php' >return to login page</a> </p>";
}
}
else die ('password didnt match');
}
//end second if
else die ('please fill in all data');
}
?>
<html>
<h2> registration </h2> <br>
<form action="register.php" method="POST">
<table>
<tr>
<td>
Your full name::
</td>
<td>
<input type="text" name="fullname" value='<?php echo $fullname; ?>'>
</td>
</tr>
<tr>
<td>
Choose a username::
</td>
<td>
<input type="text" name="username" value='<?php echo $username; ?>'>
</td>
</tr>
<tr>
<td>
Choose a password::
</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td>
Repeat a password::
</td>
<td>
<input type="password" name="repeatpassword">
</td>
</tr>
</table>
<p>
<input type="submit" name="submit" value="Register">
</html>