Here is the registering part of the code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="eg.css" />
</head>
<body vlink="#c0c0c0">
<?php
if ($submit)
{
if (strlen($username) < 4 || strlen($password) < 4)
{
echo "Username and Password must be atleast 4 characters.\n";
}
else
{
// process form when submit is clicked
$db = mysql_connect("localhost", "root");
mysql_select_db("members",$db);
$sql = "INSERT INTO members (username, password, fname, lname, email) VALUES ('$username','$password','$fname','$lname','$email')";
$result = mysql_query($sql);
echo "Thank you for signing up.\n";
}
}
else
{
// display form before submit button is clicked
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<h3>Username:</h3><input type="Text" name="username">
<h3>Password:</h3><input type="password" name="password">
<h3>First Name:</h3><input type="Text" name="fname">
<h3>Last Name:</h3><input type="Text" name="lname">
<h3>E-Mail:</h3><input type="Text" name="email">
<br><br>
<input type="Submit" name="submit" value="Submit">
</form>
<?php
} // end if
?>
</body>
</html>
Here is the login section:
<html>
<head>
<link rel="stylesheet" type="text/css" href="eg.css" />
</head>
<body>
<?php
if($submit)
{
$db = mysql_connect("localhost", "root");
mysql_select_db("members",$db);
$user = "SELECT username,password FROM members WHERE username = '$username' AND password =
'$password'";
$result = mysql_query($user);
if (mysql_num_rows($result) > 0)
{
echo "Yeah";
}
else
{
echo "shit";
}
}
else
{
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<h3>Username:</h3><input type="Text" name="username">
<h3>Password:</h3><input type="password" name="password">
<input type="submit" name="submit" value="submit">
<?php
}
?>
</body>
</html>