Jump to content

[SOLVED] login script help


sineadyd

Recommended Posts

Hi,

Can anyone spot errors that I may have missed here because its really annoying me!I have a "users" db and tables for "admin","members" and "register" in it.I will only be using members and admin for this script, but whatever it is, it just will not connect to the database.

any help would be really reeeeeally appreciated!

Thanks in advance!

<?php
//Users Database settings
    $host="localhost";
    $username="root";
    $password="";
    $db_name="users";

//Connect to server and select database.
    $dbc= mysql_connect("$host","$username","$password") or die("connection was unsuccessful");
$dbc= mysql_select_db($db_name)or die("Database connection was unsuccessful");
if (is_null($dbc) && !(is_resource($dbc))) 
{
   		die('Error getting connection.');
}
    
//User database tables needed.
   // $tbl_memb="members";
   // $tbl_admin="admin";

//create and issue the query
    $username=$_POST['USERNAME'];
    $password=$_POST['PASSWORD'];

    $sqlmemb="SELECT * FROM members WHERE
    username = '$username' and password='$password'";
    $resultmemb= mysql_query($sqlmemb) or die(mysql_error());
//get the number of rows in the result set
//should be 1 if theres a match
    $isset1=mysql_num_rows($resultmemb);

    $sqlamin="SELECT * FROM admin WHERE 
username='$username' and password='$password'";
    $resultadmin= mysql_query($sqlamin) or die(mysql_error());
//get the number of rows in the result set
// should be 1 if theres a match
    $isset2=mysql_num_rows($resultadmin);
          
	                    //------------//
                            //member login//
                            //------------//
//If isset1(members login) is equal to 1 then the members homestart page is opened.
    if($isset1==1)
    {
?>
    <script language="javascript">
    window.open('../www/homestart.htm','',
    config='scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes')</script>
<?php
    //create display string
    $display_block=" <p> ".$username." is authorised!</p>";
    include 'Login.html';
}
                            //-----------//
                            //admin Login//
                            //-----------//
else
if ($isset2==1) //If admin details are correct then it will open the administrators homestart page is opened.
{
?>
<script language="javascript">
window.open('../admin/homestart.htm','',
config='scrollbars=yes,menubar=no,height=850,width=955,resizable=yes,status=yes')</script>

<?php
//create display string
    $display_block=" <p> ".$username."  is authorised!</p>";
    include 'Login.html';
}
                            //------------//
                            //Redirection//
                            //-----------//
else
if ($isset1==0 OR $isset2==0)//If the username enters wrong details then an error is displayed
{                            // and they are redirected back to the login page.
    echo '<html>'."n".'<body><div class="disfunction">Sorry, the Username and password you have entered are incorrect!</div></body>'."n".'</html>';
    include 'Login.html';
    exit;
}

//set authorisation cookie
    setcookie("auth", "1", 0, "/","Login.html", 0);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>successlogin.php</title>
</head>
<body>
<?php echo "$display_block";?>
</body>
</html>

 

 

Link to comment
https://forums.phpfreaks.com/topic/102688-solved-login-script-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.