|
-
Nov 23rd, 2007, 02:42 PM
#1
Thread Starter
Lively Member
login script info dont match
everytime i try to login, i recieve "'The name and password entered do not match those on file."
can anybody help fix this please
Code:
<?php
if (isset($_POST['submitted'])) {
require_once ('./mysql_connect.php');
function escape_data ($data){
global $dbc;
if(ini_get('magic_quotes_gpc')){
$data = stripslashes($data);
}
return mysql_real_escape_string
(trim($data), $dbc);
}
$errors = array();
if (empty($_POST['first_name'])) {
$errors[] = 'You forgot to enter your Name.';
} else {
$fn = escape_data($_POST['first_name']);
}
if (empty($_POST['password'])) {
$errors[] = 'You forgot to enter your password.';
} else {
$p = escape_data($_POST['password']);
}
if (empty($errors)) { // If everything's OK.
$query = "SELECT id, name, runing FROM user WHERE name='$fn' AND pass=SHA('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {
if($row['2'] == "Stop"){
$page_title = 'Login';
include ('./main.html');
echo '<font size="8" color="red">Sorry but your account but been stop <P>by the administrator of this web page</font>';
include ('./end.html');
exit();}
setcookie("bank", $row[1], time()+3600);
//session_name ('bank_ID');
//session_start();
//$_SESSION['name_ID'] = $fn;
header("Location: ./index.php");
exit();
} else {
$errors[] = 'The name and password entered do not match those on file.';
}
}
mysql_close();
} else {
$errors = NULL;
}
$page_title = 'Login';
include ('./main.html');
if (!empty($errors)) {
echo '<h1 id="mainhead">Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) {
echo " - $msg<br />\n";
}
echo '</p><p>'.strval($pass).'Please try again.</p>';
}
?>
<h2>Login</h2>
<form action="login.php" method="post">
<p>SL Name: <input type="text" name="first_name" size="25" maxlength="40" /> </p>
<p>Password: <input type="password" name="password" size="25" maxlength="20" /></p>
<p><input type="submit" name="submit" value="Login" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<a href="./setup.php"><font color="##ffffff">[</font> Free Sign-up <font color="##ffffff">]</font></a>
</form>
<?php
include ('./end.html');
?>
-
Nov 25th, 2007, 01:24 PM
#2
Addicted Member
Re: login script info dont match
Echo out your query before running it. If it doesn't execute print the mysql_error() to see what is the error, if there is any.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|