Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-09-2005, 05:05 PM Login troubles
sk8boarder2424's Avatar
Extreme Talker

Posts: 175
Location: Lockport Illinois
Trades: 0
ok... im kinda new to php, and i've been having some trouble getting anything right

so heres what i got:
My login form:
Code:
<?php

echo '<form method="POST" action="validate.php">
	  &nbsp;<b>Username</b>:<br>
	  &nbsp;<input type="text" name="user_var" onfocus=this.value="" class="login" value="Username"><br>
	  &nbsp;<b>Password</b>:<br>
	  &nbsp;<input type="password" name="pass_var" onfocus=this.value="" class="login" value="Password"><br>
	  &nbsp;<input type="submit" value="Login"><br><a href="#">Register</a>
	   </form>'
?>
Validate.php:
Code:
<?php
	session_start();
	$db_user = 'root';
	$db_pass = 'dorkbear';
	$username = $_POST['username'];
	$password = $_POST['password'];

	$connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
	mysql_select_db('loginMattsMods', $connection) or die(mysql_error());

	$query = "SELECT * FROM users 
			WHERE username='$username' AND password='$password'";

	$result = mysql_query($query, $connection) or die('error making query');
	$affected_rows = mysql_num_rows($result);

	if($affected_rows == 1) {
		print 'validated';
	}
	else {
		print 'not valid';
	}
?>
please help!

-matt
__________________
"People created God in an effort to explain the unknown and soothe their fear of death."

-beasters
sk8boarder2424 is offline
Reply With Quote
View Public Profile Visit sk8boarder2424's homepage!
 
 
Register now for full access!
Old 05-09-2005, 05:37 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
This might be wrong but....

the variables you are posting with the form from the input text boxes are 'user_var' and 'pass_var' but in the validation you collect the variables 'username' and 'password' from the $_POST. You need to match them up and that should sort it.
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 05-09-2005, 06:32 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
Nailed on the head!
$_POST['username']; should be $_POST['user_var']; and $_POST['password']; should be $_POST['pass_var'];
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 05-09-2005, 07:18 PM
sk8boarder2424's Avatar
Extreme Talker

Posts: 175
Location: Lockport Illinois
Trades: 0
unfortunetly that wasnt my big problem...
http://beasters.serveftp.com
login with this info:
username: beasters
password: dorkbear
this was the only real problem
__________________
"People created God in an effort to explain the unknown and soothe their fear of death."

-beasters
sk8boarder2424 is offline
Reply With Quote
View Public Profile Visit sk8boarder2424's homepage!
 
Old 05-09-2005, 09:24 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
That problem means that the password set for mysql is either corrupt or.....well lets just say it's not right as I don't know exactly how to explain it, I just know that going into mysqladmin and changing your password should work.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 05-09-2005, 11:41 PM
sk8boarder2424's Avatar
Extreme Talker

Posts: 175
Location: Lockport Illinois
Trades: 0
hmmm... could you walk me through doing that through MySQL Command Client? I don't have any fancy scripts or Control Pannels, its runnin on my spare PC.
__________________
"People created God in an effort to explain the unknown and soothe their fear of death."

-beasters
sk8boarder2424 is offline
Reply With Quote
View Public Profile Visit sk8boarder2424's homepage!
 
Old 05-10-2005, 07:29 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
http://dev.mysql.com/doc/mysql/en/re...rmissions.html

The MySQL documentation is a beautiful thing.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Login troubles
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.52934 seconds with 12 queries