Results 1 to 3 of 3

Thread: Login no longer works

  1. #1
    Join Date
    Jul 2006
    Thanked 1 Time in 1 Post

    Default Login no longer works

    For some reason a login script I've been using has suddenly decided to stop working and keeps returning the error "Unable to establish a DB connection"... despite the fact it doesn't use one in the first place. If it doesn't produce that error it simply returns to the page telling you to login rather than give you the main site.

    The script is being used in three locations. It has stopped working on my local server and on an external server. On the other external server it is working though. I have tried downloading the files from the working server to use on others but it won't work.

    Can anybody see what the problem might be?

    $TARGET = "/"; // go to this page if login ok
    //SETUP, insert your users and passwords
    $users = array("demo", "admin");
    $passwords = array("demo_pass", "password");
    		for($i=0; $i!= sizeof($users); $i++){
    			if($users[$i] == $_POST['username']){
    				if($passwords[$i] == $_POST['password']){
    					$_SESSION['login'] = true;
    					header("location: ".$TARGET);
    		$msg = "An error occurred. Please try again.";
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <link href="/templates/Spectrum/master.css" rel="stylesheet" type="text/css" />
    <div id="container">
      <div id="innerCont">
    	<!-- // Spectrum // Begin main structure -->
    	<div class="mastWarn">
    	<h2>Protected Content</h2>
    	<p>To access this content you must be a member of staff. Contact the Station Manager for login information.</p>
    	<div id="content">	
    	<!-- // Spectrum // Page Content -->
    	<form id="form1" name="form1" method="post" action="?login">
      <table width="370" border="0">
        <?php if(isset($msg)) echo "<tr>
          <td colspan=\"2\" class=\"error\">".$msg."</td>
          <td width="175"><div align="right"><strong>Username:</strong></div></td>
          <td width="185"><label>
            <input type="text" name="username" value="demo"/>
          <td><div align="right"><strong>Password:</strong></div></td>
            <input type="password" name="password" value="demo_pass"/>
            <input type="submit" name="button" id="button" value="Login" />
    <p>Testing Login<br /><br />Username: demo<br />Password: demo_pass
    	<hr />
    <!-- // Spectrum // End Page Content -->
    	<div id="footer"><hr /><p>&copy; 2010</p></div>
    	<!-- // Spectrum // End main structure -->

  2. The Following User Says Thank You to ChroniX For This Useful Post:

    infocusweb (06-12-2010)

  3. #2
    Join Date
    Apr 2008
    Thanked 516 Times in 502 Posts
    Blog Entries


    Well, if it was working and now it's not, the simple rule is that something changed. There's nothing in this code that would return an error message about a database, so what on your site would? Are you actually being logged in, and then the page you are redirected to connects to a DB but can't find it?

    About going back to the login page - do the other pages on your site check for $_SESSION['login']? If it's not set do they send the user back to the login page? That might be happening too.

    You should also move your session_start() line to the very top, immediately after <?php . If anything (anything) is output to the browser, including an error message, before the session is started, then it won't work.

  4. #3
    Join Date
    Jun 2010
    Thanked 0 Times in 0 Posts

    Default hello

    i have set log in page and i have requirement that after a few second automatic log out the page so which type of coding use in php.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts