Not Correct Login

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

hmmm..... are you going to maek us guess at what line 9 is??
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

SilverMist wrote:It says Parse Error, Line 9. Possibly from the quotations?
seeing some of the final code your using that is generating the error would possibly be helpful.
timhortons
Forum Commoner
Posts: 29
Joined: Thu Jan 15, 2004 11:48 am
Location: Calgary, AB, Canada

Post by timhortons »

Well, the new releases have changed to $_GET/$_POST and whatnot, and scripts should be written with those instead, but I mean, when i was learning PHP i didnt wanna tinker with all my get/post variables :P

Nevermind me! just voicing an irrelevant personal opinion obviously.
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

I am using Goowe's (sp?) code. Unfortunately now it is informing me that my table does not exist. However my table would have to exist in order to register!
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

I edited it and it should work now. The posts came so fast after I told you.

Code: Select all

<?php
$host = "localhost";
$dbusername = "user";
$password = "pass";
$database = "db";

// Connect to mysql and database
$link = mysql_connect($host, $dbusername, $password)
	or die("<P>Could not connect: ".mysql_error()."</P>");
mysql_select_db($database) 
	or die("<P>Could not select database</P>");                   

$username = $HTTP_POST_VARS['txtName'];
$password = $HTTP_POST_VARS['txtPassword'];

$query = "SELECT * FROM Members WHERE Name = '".$username."' AND Password = '".$password."'";
$result = mysql_query($query) or die("<P>Query failed: ".mysql_error()."</P>");

// Check to see if user exists
if(mysql_num_rows($result) > 0)
{
	// Make cookie for user
	if(setcookie("loginname", $username))
	{
		echo "Welcome";
	}
		else
	{
		echo "Error setting cookie.";
	}
}
	else
{
	echo "Failed login.";
}
?>
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Still doesn't work :'(
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

*sneeze*

What is the error? No table there?
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Yep still getting that error :cry:
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

Code: Select all

<?php
$query = "SELECT * FROM Members WHERE Name = '".$username."' AND Password = '".$password."'";
?>
Since I'm not the person who wrote your original code, I don't know what the name of your table really is. Make sure in your mySQL database that the table that holds the user information is entitled "Members" and nothing else. If it's something different, you'll have to change the "Members" part in the code above to the exact name of the table.
User avatar
SilverMist
Forum Commoner
Posts: 65
Joined: Tue Mar 02, 2004 2:06 pm
Location: Canada
Contact:

Post by SilverMist »

Wait...then I'd have to split up my code. Would I be able to do that?
Goowe
Forum Commoner
Posts: 94
Joined: Mon Mar 15, 2004 9:51 am
Location: Southeast Alaska

Post by Goowe »

Sorry, I'm now considered confused :oops: Can you explain what you're questioning?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

SilverMist wrote:Wait...then I'd have to split up my code. Would I be able to do that?
spilt up your code?? All you ahve to do is make sure your actually SELECTing fromt he right table.... "Members" change to whatever the real table's name is
Post Reply