Login Adminsitration struggles

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

justin
New php-forum User
New php-forum User
Posts: 11
Joined: Sun Oct 13, 2002 8:30 pm
Location: toronto
Contact:

Login Adminsitration struggles

Postby justin » Thu Dec 05, 2002 5:14 pm

Hello,
I am trying to create a login page for my admin site, which starts a session, If the admin name and pass are in db (logged in), they get a main menu buttun and a session is started. If not in db they get a try again link. Whats happeneing is that the page is coming up blank, no errors, just blank.

The do_html_url() function is a function in outputFns.php which diplays the links. This is my code , can someone help please.

<html><head></head><body>
<?
include_once("outputFns.php");
?>
<?
function login($username, $password)

{ // begin login function
// this function checks the username and password with the db table for admin users
// connect to db
// check if username is unique
$db_name = "xxxxxxxxxxx";

$table = "admin";

//1

$connection = @mysql_connect("xxxxxxx", "xxxxxxx", "xxxxx") or die("Problems connecting - Try again");

//2

$result = mysql_query("SELECT adminID, adminName, adminPass FROM '$table' WHERE adminName='$username' AND adminPass ='$password'");

if(!$result)

do_html_url("login.php", " Wrong Login Infromation try agin");


if(mysql_num_rows($result) > 0)

do_html_url("MenuView.php", " Welcome to the Adminsitration Site");
session_register('valid');
$valid = "yes";

else

do_html_url("login.php", " Wrong Login Infromation try aagin");


} // end login() function
?>
</body></html>

meannate
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Nov 04, 2002 12:06 pm
Location: West Los Angeles
Contact:

An Idea?

Postby meannate » Mon Jan 06, 2003 5:36 pm

Try this on for size:

Code: Select all

<HTML>
<HEAD>
<?
$connection = @mysql_connect("hostname", "admin", "pass") or die("Couldn't Connect to Database");
$db = @mysql_select_db("admin", $connection) or die("Couldn't Select Database");

if (!$username || !$password) {
   header("Location: login.php?msg=Please Enter Both Required Fields");
   exit;
} else {
   $sql = "SELECT adminID, adminName, adminPass FROM admin WHERE adminName=\"$username\" AND adminPass = \"$password\"";
   $result = @mysql_query($sql, $connection) or die("Couldn't Query Database");

   if (mysql_num_rows($result)) {
      $valid = "yes";
      session_register('valid');
      header("Location: login.php?msg=Successful Login");
      exit;
   } else {
      header("Location: login.php?msg=Incorrect Login Password Combo");
      exit;
   }
}
?>
</HEAD>
<BODY>
</BODY>
</HTML>


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron