Jump to content


Photo

Still have problem with 'header'


  • This topic is locked This topic is locked
3 replies to this topic

#1 devileyes

devileyes
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 30 August 2006 - 01:47 PM

I put it like this but it gives an error - Could not select database because No Database Selected

<?php
include "connect.php";

if (logIn($_POST['username'], $_POST['password']) )
  header("Location: adminarea.html");
else
  die;
 
function logIn($uid, $pwd) {
  // connect to the mysql server
  $link = mysql_connect($server, $db_user, $db_pass)
    or die ("Could not connect to mysql because ".mysql_error());

  // select the database
  mysql_select_db($database)
    or die ("Could not select database because ".mysql_error());

$match = "select id from $table1 where username = '$uid'
          AND password = '$pwd'";

  $qry = mysql_query($match)
    or die ("Could not match data because ". mysql_error());
  $num_rows = mysql_num_rows($qry);

  if ($num_rows <= 0) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body bgcolor="#000000" text="#FF0000" link="#FFFF00" vlink="#FFFF00" alink="#FFFF00">
<div align="center">
<?php
    echo "<p>wrong username or password !</p>";
    echo "<a href=adminlogin.html>Go Back</a>";
return false;
  }
  else
  return true;
}
?>

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 30 August 2006 - 01:50 PM

include('connect.php');

I assume this contains all teh login stuff for the database - put the mysql_connect and mysql_select_db in that file too - then you don't need to put it in every page!

seems an awfully convoluted method of doing things IMO
follow me on twitter @PHPsycho

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 30 August 2006 - 01:55 PM

PLEASE do not keep starting new threads that are all about the same problem!

Your question as posted here is much simpler to understand and solve if left in the context of all the discussion and help provided in your earlier thread(s) on exactly the same problem.

I assume you have read the forum rules. Please abide by them.

Here is where you should continue this discussion - http://www.phpfreaks....html#msg424620
Legend has it that reading the manual never killed anyone.
My site

#4 devileyes

devileyes
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 30 August 2006 - 01:55 PM

include('connect.php');

I assume this contains all teh login stuff for the database - put the mysql_connect and mysql_select_db in that file too - then you don't need to put it in every page!

seems an awfully convoluted method of doing things IMO


Still give the same error




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users