Jump to content


Photo

Login -- I need help :(


  • Please log in to reply
3 replies to this topic

#1 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 03 October 2006 - 08:38 PM

I get no errors, but, when it goes to sign you in it takes you to 'login.php?action=Login' (like it's supposed to, but, it shows the log in script again...
here is the code.
please help!
<?php
include ("global.php");


if ( $_POST['action'] == "Login" )
{
	$get_user = @mysql_query( "SELECT * FROM `users` WHERE `username` LIKE '" . strip( $_POST['username'] ) . "'" );
	$count_user = @mysql_num_rows( $get_user );
	$user = @mysql_fetch_array( $get_user );
	
	$enc_pass = ( $_POST['password'] );
	
		if ( empty( $_POST['username'] ) )
		{
		
			echo ( success( "You forgot to enter a username.", "Error" ) );
		}
		elseif ( empty( $_POST['password'] ) )
		{
			
			echo ( success( "You forgot to enter your password.", "Error" ) );
		}
		elseif ( $count_user == 0 )
		{
		
			echo ( success( "The username you entered does't exist.", "Error" ) );
		}
		elseif ( $enc_pass != $user['password'] )
		{

			echo ( success( "Passwords don't match, try again.", "Error" ) );
		}
		else
		{
			setcookie( "uid", $user['uid'], time() + 31536000, "/" );
			
				echo ( success( "You are now logged in... Have fun :) $update", "Success" ) );
			$update = @mysql_query( "UPDATE `users` SET `login`='$day' WHERE `uid`='{$user['uid']}'" );

		}
	}

else {

echo"<center>";
echo"<br />";
echo"<form method='post' action=login.php?action=Login>";
echo"<table border='0' cellspacing='0' class='border' width='500'>";
echo"<tr>";
echo"<td align='center' colspan='2'>Login</td>";
echo"</tr>";
echo"<tr>";
echo"<td align='center'><strong>Username:</strong></td>";
echo"<td align='left'><input type='text' name='username'></td>";
echo"</tr>";
echo"<tr>";
echo"<td align='center'><strong>Password:</strong></td>";
echo"<td align='left'><input type='password' name='password'></td>";
echo"</tr>";
echo"<tr>";
echo"<td align='center' colspan='2'><input type='submit' value='Login'></td>";
echo"</tr>";
echo"</table>";
echo"</form></center>";
}

?>


#2 JayBachatero

JayBachatero
  • Members
  • PipPipPip
  • Advanced Member
  • 296 posts
  • LocationQueens NY

Posted 03 October 2006 - 08:43 PM

Well you are not redirecting the user to any location.  Use header('Location: http://...');
JayBachatero
SMF Developer && Converter Specialist

#3 ataria

ataria
  • Members
  • PipPipPip
  • Advanced Member
  • 179 posts

Posted 03 October 2006 - 08:46 PM

Where would I use that?

#4 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 03 October 2006 - 09:27 PM

That's not your primary problem here,

Change --> if ( $_POST['action'] == "Login" )

to --> if ( $_GET['action'] == "Login" )

for it to work as you intended in this script (POST to GET on THAT variable)

Still it would be better to name the submit button e.g. "submit" and then sniff for --> if(isset($_POST['submit']))
....then removing the get variable in your form action....

Just a point of view though..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users