Trying to create an authentication and tracking script
this is what i have done can any one tell me if im doing this rite
< ?
/*
Basic Login Script
(c)
$db_host = “localhost”;
$db_user = “root”;
$db_pass = “”;
$db_name = “user”;
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die (“Cannot connect to database”);
// Sessions //
session_name(“sid”);
session_start();
//
if (!$_POST[‘Login’]){
// Change Email Here
$email = “
//
$ip = $
$date = date(‘Y-M-D’);
$time = time();
//
//Send’s Email to tell you about it
mail(“$email”,”Hacking attempt”,”This is an Automated Messasge, rn Ip: $ip rn Date: $date rn Time: $time rn Ty For using Arutha’s Login Script”);
//
// Redirect
$url = “index.php”;
//
echo “< meta http-equiv=”refresh” content=”5;URL=$url”>”;
//
}
else
{
//
// Check Form is filled in
//
if (!$_POST[‘user’] || !$
echo “ERROR – You need to enter all the fields”;
}
else
{
//
// Getting the vars
//
$username = $_POST[‘user’];
$password = $
$query = “SELECT * FROM users where username = ‘$username’ and password = password(‘$password’)”;
$execute = mysql_query($query);
$countrow = mysql_num_rows($execute);
if ($countrow == 1){
//
$_SESSION[‘user’] = $username;
$sid = session_id();
//
// Redirect
$url = “members.php?sid=$sid”;
//
echo “< meta http-equiv=”refresh” content=”5;URL=$url”>”;
echo “You will be redirected to the members section in 5 sections”;
//
// End //
}
else
{
die(“Your Username or Password was inncorrect please hit the back button and try agian”);
}
}
}
? >
<?php
// … we will put some php code here
?>
<html>
<head>
<title>Basic Login</title>
</head>
<body>
<?php
if ($errorMessage != ”) {
?>
<p align=”center”><strong><font color=”#990000″><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form method=”post” name=”frmLogin” id=”frmLogin”>
<table width=”200″ border=”0″ align=”center” cellpadding=”2″ cellspacing=”2″>
<tr>
<td width=”100″><strong>Username</strong></td>
<td><input name=”txtUserId” type=”text” id=”txtUserId”></td>
</tr>
<tr>
<td width=”100″><strong>Password</strong></td>
<td><input name=”txtPassword” type=”password” id=”txtPassword”></td>
</tr>
<tr>
<td width=”150″> </td>
<td><input type=”submit” name=”btnLogin” value=”Login”></td>
</tr>
</table>
</form>
</body>
</html>