mrjameer Posted November 1, 2006 Share Posted November 1, 2006 hi,i have a php script for login to my web site.it works very well when i test it in localhost but when i upload it to my site it is not allowing me login.here is the code.help me to get out of it.thanksmrjameer<?php session_start();include 'db.php';$use=$_POST['username'];$pwd=$_POST['password'];$use1=sha1($use);$pwd1=sha1($pwd);$conn4=mysql_connect($host,$username,$password);mysql_select_db($db,$conn4);$sql="SELECT * FROM $table41";$result=mysql_query($sql,$conn4);while($newarray=mysql_fetch_array($result)){ $username=$newarray['username']; $password=$newarray['password'];}$errorMessage = ''; if (isset($_POST['username']) && isset($_POST['password'])) { // check if the username and password combination is correct if ($use1 === $username && $pwd1 === $password) { // the username and password match, // set the session $_SESSION['basic_is_logged_in'] = true; // after login we move to the main page header('Location: menu1.php'); exit; } else { $errorMessage = 'Sorry, wrong username / password'; } } ?> <html> <head> <title>Basic Login</title> <style type="text/css">html, body{ margin: 0px; padding: 0px; border: 0px; background: url(bg1.gif)repeat-x;background-color:#8db0e5;}#m{ margin-left:450px; margin-top:150px;}#n{ margin-left:50px; margin-top:20px;}#o{ margin-left:560px; margin-top:20px;}</style><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php if ($errorMessage != '') { ?> <p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p> <?php } ?> <form action="" method="post" name="frmLogin" id="frmLogin"> <div id="m"> <b>PLEASE ENTER USER ID / PASSWORD</b></div> <div id="n"> <table width="400" border="1" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="150">User Id</td> <td><input name="username" type="text" id="username" size="25"></td> </tr> <tr> <td width="150">Password</td> <td><input name="password" type="password" id="password" size="27"></td> </tr> <tr> <td width="150"> </td> <td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td> </tr> </table> </div><div id="o"> <a href="javascript:window.close();">Exit</a></div></form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/ Share on other sites More sharing options...
gmwebs Posted November 1, 2006 Share Posted November 1, 2006 Have you changed the settings in your db.php file to reflect the fact that you are now on your host? Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118033 Share on other sites More sharing options...
mrjameer Posted November 1, 2006 Author Share Posted November 1, 2006 here is my db.php in which i have connections with my site phpmyadmin<?php$host="localhost";$username="abcd";$password="dcba";$db="test";$table41="clients";?> Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118039 Share on other sites More sharing options...
gmwebs Posted November 1, 2006 Share Posted November 1, 2006 Try adding a [code=php:0]OR DIE (mysql_error())[/code] after each MySQL function to see whether it is your MySQL queries that are at fault. For example, change [code=php:0]$conn4=mysql_connect($host,$username,$password);[/code] to be [code=php:0]$conn4=mysql_connect($host,$username,$password) OR DIE (mysql_error());[/code] and do the same for the other MySQL functions and then try to run the script again to see if you get any errors. Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118044 Share on other sites More sharing options...
mrjameer Posted November 1, 2006 Author Share Posted November 1, 2006 hi,i tested it putting-- or die (mysql_error()); at every mysql function.it is not showing any warnings or errors regarding mysql.it simply displays wrong username/password even if i enter the correct username/passwordmrjameer Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118059 Share on other sites More sharing options...
Anidazen Posted November 1, 2006 Share Posted November 1, 2006 I know this sounds stupid, but ya did remember to enter the info into your live DB?It's not just failing to lookup the password because you didn't put anything in there? Link to comment https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.