Can't access mysql once I put site online

I can access fine on my WAMP server on my computer. Put online and storefront is visible, so I know the login code works to show the products. No problem. But when I try to login as admin, can’t connect to db error OR could not validate userid/pwd error. Have tried various combos of userid, pwd, code changes to no avail. Any help is appreciated.

This is the validate code that validates the login:

[php]
session_start();
include ("…/mylibrary/smalllogin.php");
smalllogin();

$userid = $_POST[‘userid’];
$password = $_POST[‘password’];
$query = “SELECT * from admins where userid = ‘$userid’ and password = (’$password’)”;
$result = mysql_query($query);
if (mysql_num_rows($result) == 0)
{
echo “

Sorry, your account was not validated.


\n”;
echo “<a href=“smalladmin.php”>Try again
\n”;
} else
{
$_SESSION[‘store_smalladmin’] = $userid;
header(“Location: smalladmin.php”);
}
[/php]

This is the login form, which triggers the login php and validate php:

[php]


Store Web Site Administration

Please log in below

User Name:


Password:


[/php]

And this is the login php:

[php]
function smalllogin()
{
$con = mysql_connect(“localhost”, “dinner1_tester”, “testerpa55”) or die(‘Could not connect to server’);
mysql_select_db(“dinner1_store”, $con) or die(‘Could not connect to database’);
}
[/php]

For whatever it’s worth, this is the login code that displays the storefront data when someone logs on to the main site. It’s an auto login that is called in the index page and it works fine. But it has the userid/pwd hard coded into it and that won’t work for admin logins.

[php]
function login()
{
$con = mysql_connect(“localhost”, “dinner1_tester”, “tester”) or die(‘Could not connect to server’);
//dinner1 is the database name, tester is userid, tester is pwd
mysql_select_db(“dinner1_store”, $con) or die(‘Could not connect to database’);
}
[/php]

and here’s the validate that is called by that:

[php]
session_start();
include ("…/mylibrary/login.php");
login();

$userid = $_POST[‘userid’];
$password = $_POST[‘password’];

$query = “SELECT userid, name from admins where userid = ‘$userid’ and password = (’$password’)”;
$result = mysql_query($query);

if (mysql_num_rows($result) == 0)
{
echo “

Sorry, your account was not validated.


\n”;
echo “<a href=“admin.php”>Try again
\n”;
} else
{
$_SESSION[‘store_admin’] = $userid;
header(“Location: admin.php”);
}
[/php]

so everything works on your localhost even with an admin user?

Sponsor our Newsletter | Privacy Policy | Terms of Service