Jump to content

Help with login page


iRush

Recommended Posts

Hey guys i have a few question with this login script im trying to make. Ok so first im using php myadmin and i've created a simple login here that works fine but i want to tweak it so when i login i can login to a specific site where i've created tables and stuff. Is there anyone out there that can help me im a little stumped on how to do this. Thanks in regards. Here are my two scripts im using

 

 

show_login.html

<html>
<head>
<title>Login Form</title>
<h1>Login to Authorized Area</h1>
<form method= "post" action= "login.php">

<br> Username: <input type= "text" name= "username"> <br>
<br> Password: <input type= "password" name= "password"> <br>

<p> <input type= "submit" name= "submit" value= "Login" </p><br>
</html>
</form>

 

 

login.php

<?

if ((!$_POST['username']) || (!$_POST['password'])) {
header("Location: show_login.html");
exit;

}

$db_name="ryan";
$table_name="auth_users4";

$connection=@mysql_connect("localhost","RyanH","test1234")or die(mysql_error());

$db =@mysql_select_db($db_name, $connection)or die(mysql_error());

$sql= "SELECT * FROM $table_name WHERE username ='$_POST[username]' AND password = password('$_POST[password]')";
$result = @mysql_query($sql,$connection) or die(mysql_error());

$num=mysql_num_rows($result);

if ($num != 0) {
echo "<P>Congratulations, you're authorized!</p>";
}else{
echo "<P>You are not authorized to use this site</p>";
echo'<br/><a href="show_login.html">Try Again</a>';

exit;

}

?>

Link to comment
Share on other sites

Firstly:

 

$sql= "SELECT * FROM $table_name WHERE username ='$_POST[username]' AND password = password('$_POST[password]')";

 

You should NOT use the MySQL password function.

 

The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications.

 

That being said, you didn't really state what's wrong. So, what's the problem?

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.