Jump to content

Login -- I need help :(


ataria

Recommended Posts

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!
[code]<?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>";
}

?>
[/code]
Link to comment
Share on other sites

That's not your primary problem here,

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

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

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..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.