473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Incorrect password

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Simple Database Connection</title>
</head>
<body bgcolor="white">

<?php
$connection = mysql_connect("localhost", "root", "phpmysql");
$select_db = mysql_select_db("procdumy", $connection);
$query = mysql_query ("SELECT username, password FROM users", $connection);


if(isset( $_COOKIE['ID_my_site']))

//if there is, it logs you in and directes you to the members page
{
$name = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT password FROM users WHERE username = '$username'")or die(mysql_error());
//$check = mysql_query("SELECT cust_username,cust_pswrd FROM customer WHERE cust_username = '$cust_username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
if ($pass != $info['password'])
{
}
//else
//{
//header("Location: welcome.php");

//}
}
}

//if the login form is submitted
if (isset( $_POST['submit'])) { // if form has been submitted

// makes sure they filled it in
if(! $_POST['name'] | ! $_POST['pass']) {
die('You did not fill in a required field.<a href=login.php>back</a>');
}
// checks it against the database

if (!get_magic_quotes_gpc()) {
$_POST['email'] = ( $_POST['email']);
$_POST['email'] = addslashes( $_POST['email']);
}
$check = mysql_query("SELECT password FROM users WHERE username = '". $_POST['name']."'")or die(mysql_error());

//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database.

<a href=reg.php>Click Here to Register</a>');
}
while($info = mysql_fetch_array( $check ))
{
$_POST['pass'] = stripslashes( $_POST['pass']);
$info['password'] = stripslashes($info['passwordd']);
$_POST['pass'] = md5( $_POST['pass']);

///*
//gives error if the password is wrong
//if ( $_POST['pass'] != $info['password']) {
//if (md5( $_POST['pass'] ,$info['cust_pswrd'] ==$info['cust_pswrd'])){
if ( $_POST['pass']!= $info['cust_pswrd']) {
echo $_POST['pass']."<br>\n";
echo $info['password']."<br>\n";
die('Incorrect password, please try again.<a href=login.php>Click Here </a>');
}
else
{
//*/
// if login is ok then we add a cookie
$_POST['name'] = stripslashes( $_POST['name']);
$hour = time() + 3600;
//setcookie(ID_my_site, $_POST['name'], $hour);
//setcookie(Key_my_site, $_POST['pass'], $hour);

//then redirect them to the members area
header("Location: welcome.php");
}
}
}
else
{

// if they are not logged in
?>
<TR>
<TD><IMG height=115 src="resources/visitorsBanner.png" width="100%"></TD>
</TR>
<form action="<?php echo $_SERVER['../test/PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Login</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="name" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="50">
</td></tr>
<tr>
<td colspan="2" align="right"> <input type="submit" name="submit" value="Login">
<input type="Reset" value="Clear Form" ></td>
</tr>
</table>
</form>
<?php
}

?>

</body>
</html>

I am trying to log on with this code everything else works but the password say its incorrect.on the database it it 32bits long I cant see where my proble is.
Any bright idea for me on what s wrong??
tried all the commented codes.

Thanx


I am trying to log on with this code everything else works but the password say its incorrect.on the database it it 32bits long I cant see where my proble is.
Any bright idea for me on what s wrong??
tried all the commented codes.

Thanx
Sep 4 '06 #1
2 4835
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\php\dumy\login.php:9) in C:\Program Files\Apache Group\Apache2\htdocs\php\dumy\login.php on line 86

Oh the password I did see the mistake eventually after a week looking at the code.now it gives me the heasder location error above.
Sep 4 '06 #2
Banfa
9,065 Expert Mod 8TB
I merged your threads because the second one did not make sense if you hadn't read the first one and I have moved them to the PHP forum since that's what they are about.

On to the problem

In PHP you can only call the header() function before you output and of the actual page because the headers have to be sent first. As soon as you output any other data either using print, echo or just having it in the file (like your DOCTYPE) then PHP sends all the current headers and your chance to modifiy them has passed.

You need to alter the page so that it sets the headers before it outputs any of the page.
Sep 4 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Amit D.Shinde | last post by:
Hi Experts, i am writting a stored procedure in sql server 7. Its a simple stored procedure It is my first stored procedure. I want insert a record in table if the primary key field user id...
3
by: teddysnips | last post by:
In the script below is the DDL to create some tables and a UDF. What I'm interested in is the UDF at the end. Specifically, these few lines: --CLOSE OTRate --DEALLOCATE OTRate ELSE --...
2
by: Roger R. Smith | last post by:
I see this error in my ASP .NET code: I am trying to execute the following: private const string SQL_SELECT_USER = "SELECT User.Email, User.FirstName, User.LastName, User.Status, User.Phone,...
1
by: bdastani | last post by:
I am trying to initialize a dataReader in C#, but I keep on gettin an exception error stating the following: System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,...
11
by: Mark Findlay | last post by:
Hello Experts! I am attempting to use the OleDbCommand.ExecuteScaler() function within my ASP.NET C# web page to perform a simple validation, but receive the following error: "Incorrect...
2
by: partybob99 | last post by:
I am trying to call SP_Password from some vb.net code. This should be very straight forward but no matter what I do, I keep getting errors. Here is the code strConnectString = "Data Source=" +...
2
by: ads | last post by:
we have just migrated to a new server both with database and web server- migrating all web projects and all databases.then we decided to rename the new server.we tried running all web projects on...
0
by: rajpatel50 | last post by:
Hi all, I’m seeing some strange behaviour when using an Unmanaged OLEDB Microsoft driver (v5.0.0.919 as supplied with Host Integration Server) to access DB2 on an iSeries (V5R3) via C# code ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.