/    Sign up×
Community /Pin to ProfileBookmark

Authentication help

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 = “[email protected]“;
//
$ip = $_
SERVER[‘REMOTE_ADDR’];
$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’] || !$_POST[‘pass’]){
echo “ERROR – You need to enter all the fields”;
}
else
{
//
// Getting the vars
//
$username = $_POST[‘user’];
$password = $_
POST[‘pass’];
$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″>&nbsp;</td>
<td><input type=”submit” name=”btnLogin” value=”Login”></td>
</tr>
</table>
</form>
</body>
</html>

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @benzspida spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...