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?
Login.php:
Code:<?php $TARGET = "/"; // go to this page if login ok //SETUP, insert your users and passwords $users = array("demo", "admin"); $passwords = array("demo_pass", "password"); session_start(); if(isset($_GET['login'])){ 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Extranet</title> <link href="/templates/Spectrum/master.css" rel="stylesheet" type="text/css" /> </head> <body> <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> <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> </tr>";?> <tr> <td width="175"><div align="right"><strong>Username:</strong></div></td> <td width="185"><label> <input type="text" name="username" value="demo"/> </label></td> </tr> <tr> <td><div align="right"><strong>Password:</strong></div></td> <td><label> <input type="password" name="password" value="demo_pass"/> </label></td> </tr> <tr> <td> </td> <td><label> <input type="submit" name="button" id="button" value="Login" /> </label></td> </tr> </table> </form> <p>Testing Login<br /><br />Username: demo<br />Password: demo_pass <hr /> <!-- // Spectrum // End Page Content --> </div> <div id="footer"><hr /><p>© 2010</p></div> <!-- // Spectrum // End main structure --> </div> </div> </body> </html>



Reply With Quote


Bookmarks