Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,182 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,115 people online right now. Registration is fast and FREE... Join Now!




Registration Working, Login Not

 
Reply to this topicStart new topic

Registration Working, Login Not, Urgent -- help requested!!

Sonastylol
25 Aug, 2008 - 10:08 PM
Post #1

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 129


My Contributions
I truly appreciate your help everyone and I am dying to know what I am accidentally omitting.. It's my week off before school and I'm done with work and I would love to have this working by today, Tuesday. I have taken the time to link you to all 3 webpages, as well as post the source on pastebin.ca for each page. Your time is much appreciated.


correctly inputting username and password brings you to the "wrong user/pass" screen..
Registration works great, login fails. (confirmed by checking table in database)

What gives?

http://progressiongames.com/testphp2/register.php http://pastebin.ca/1184990
http://progressiongames.com/testphp2/login.php http://pastebin.ca/1184989
http://progressiongames.com/testphp2/members.php http://pastebin.ca/1184987

Thanks!!!
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades
RE: Registration Working, Login Not
25 Aug, 2008 - 10:31 PM
Post #2

Cantankerous Old Fart
Group Icon

Joined: 23 Aug, 2008
Posts: 862



Thanked: 89 times
Dream Kudos: 50
My Contributions
php
if(!$_POST['username'] | !$_POST['pass'])


I don't think you're looking to do a bitwise OR on these fields.

EDIT: Oh, and after the redirect, call exit() so you stop processing the script.

This post has been edited by JackOfAllTrades: 25 Aug, 2008 - 10:36 PM
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Registration Working, Login Not
25 Aug, 2008 - 10:47 PM
Post #3

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
use strcmp() function for comparing password with that of database
and give it a try again

remember strcmp returns *0* if both strings r equal
so do as follows

if(0=== strcmp(password1,password2))
{
//proceed to loginpage
}
else
{
//proceed to errorpage
}

hope it helps cool.gif
User is offlineProfile CardPM
+Quote Post

Computer_
RE: Registration Working, Login Not
25 Aug, 2008 - 10:52 PM
Post #4

New D.I.C Head
*

Joined: 22 Aug, 2008
Posts: 16



Thanked: 1 times
My Contributions
Are you sure , when you record the password in the database it's MD5 encrypted ?
User is offlineProfile CardPM
+Quote Post

Sonastylol
RE: Registration Working, Login Not
26 Aug, 2008 - 05:16 AM
Post #5

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 129


My Contributions
My password in the database is being displayed as 8287458823facb8ff918, so yes, I would say the password is being md5 encrypted.

I fixed line 31 by placing another | in between the check.

Im not sure what to do about anything. If you have time today to help me make this work, I would appreciate it SO much.


Here are my files again updated with PHP source. I did a real *facepalm* action by not selecting PHP as the source.


Login.php http://pastebin.ca/1185273
Members.php http://pastebin.ca/1185275
Register.php http://pastebin.ca/1185276

Any assistance you can provide would be great. If the system is really unsafe and it's an easy fix, PLEASE help assist me in making this be working, safe code. Thank you
User is offlineProfile CardPM
+Quote Post

JackOfAllTrades
RE: Registration Working, Login Not
26 Aug, 2008 - 05:59 AM
Post #6

Cantankerous Old Fart
Group Icon

Joined: 23 Aug, 2008
Posts: 862



Thanked: 89 times
Dream Kudos: 50
My Contributions
Don't forget to call exit() after you redirect.
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Registration Working, Login Not
26 Aug, 2008 - 07:16 AM
Post #7

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 403



Thanked: 38 times
Dream Kudos: 75
My Contributions
does your password column in your database allow at least 32 characters? If not it's cutting the encyption off (truncating the data), therefore making your md5(password) wrong

Simply update the field and your system will work - if that is the problem
User is offlineProfile CardPM
+Quote Post

Sonastylol
RE: Registration Working, Login Not
26 Aug, 2008 - 07:28 AM
Post #8

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 129


My Contributions
OK So my login is now working.

On my members.php page,

I want it to display the users information. How come it isn't displaying "Welcome (username)"?

Here is the members.php code:
CODE

<?php
// Connects to your Database
mysql_connect("localhost", "******", "*****") or die(mysql_error());
mysql_select_db("progress_registeredusers") or die(mysql_error());

//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM user WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{

//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}

//otherwise they are shown the admin area
else
{
echo "Welcome ";
echo $_SESSION['username'];
echo "<p>";

echo "<a href=logout.php>Logout</a>";

}
}
}
else

//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>


This post has been edited by Sonastylol: 26 Aug, 2008 - 10:19 AM
User is offlineProfile CardPM
+Quote Post

Sonastylol
RE: Registration Working, Login Not
26 Aug, 2008 - 10:36 AM
Post #9

D.I.C Head
**

Joined: 15 Dec, 2007
Posts: 129


My Contributions
Really slowing down my progress... anyone able to help me?

I think it has something to do with $_Session

I don't think I ever created a session.. in that case, how can I get data pulled from the database? =/

And on that note, how would I edit a value from the database as well?

Like, adding or subtracting points from a "points" variable

**EDIT**

Ok looks like this was the solution:

CODE
echo "Welcome ",$info['username'], "!";


Now what about editing variables?

This post has been edited by Sonastylol: 26 Aug, 2008 - 10:49 AM
User is offlineProfile CardPM
+Quote Post

brandon99337
RE: Registration Working, Login Not
26 Aug, 2008 - 03:39 PM
Post #10

D.I.C Head
**

Joined: 14 Feb, 2008
Posts: 144



Thanked: 2 times
My Contributions
To edit a value in the database you use the UPDATE query.

CODE

mysql_query("UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value");



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:50AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month