iRush Posted December 12, 2011 Share Posted December 12, 2011 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; } ?> Quote Link to comment Share on other sites More sharing options...
ialsoagree Posted December 12, 2011 Share Posted December 12, 2011 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? Quote Link to comment Share on other sites More sharing options...
melloorr Posted December 12, 2011 Share Posted December 12, 2011 I'm not sure I understand. You want to log into the site the login script is on, but also log into a different site at the same time, with the same login script? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.