digital-overload Posted July 8, 2008 Share Posted July 8, 2008 Hi guys, I am writing to see if anyone can solve this problem as its driving me nuts!!! We have a simple login form which users data, the PHP uses a "public static function" to login the user. What we are finding is that when you submit incorrect data the form seems to submit and return errors (or reach certain points in the PHP User.Class.php file) BUT when you submit valid data the form does not seem to submit at all? Funny thing is it works on our dev box but not on the live? Here is some things to be made aware of. Live box is running PHP5.2.5 We are using the auto load function sessions are started at the top of every page in a global include -- Our Login Page -- <?php include $_SERVER['DOCUMENT_ROOT'] . 'images2/site-config.php'; $errors = array(); $email = (isset($_COOKIE['SITEImageLibraryEmail']))?$_COOKIE['SITEImageLibraryEmail']:''; $password = (isset($_COOKIE['SITEImageLibraryPassword']))?$_COOKIE['SITEImageLibraryPassword']:''; if (isset($_POST['action'])) { if (isset($_POST['remember'])) { /* * Set the session for expiry in 60 days */ session_destroy(); session_set_cookie_params(3600 * 24 * 60); session_start(); session_regenerate_id(); } $user = User::login($_POST['email'], $_POST['password-1']); if (!$user) { $errors[] = 'Email/Password combination not found'; } else { if (!$user->getActivated()) { $errors[] = 'Account has not been activated'; } elseif (!$user->getApproved()) { $errors[] = 'Account has not been approved'; } else { $_SESSION['user'] = $user; header('Location: ' . WEB_ROOT . '/'); exit; } } $email = $_POST['email']; } elseif (isset($_GET['email'])) { $email = $_GET['email']; } include DOC_ROOT . '/includes/header.php'; ?> <h1>Login</h1> <p> To login, please enter your email address and password. </p> <? if (count($errors)) { ?> <ul class="errors"> <? foreach ($errors as $error) { ?> <li><?= $error ?></li> <? } ?> </ul> <? } ?> <p>Required fields are marked with an asterisk (*)</p> <form action="" method="post"> <fieldset> <input type="hidden" name="action" value="save"/> <table cellspacing="0"> <tbody> <tr> <th><label for="frm-email"><span>* </span>Email</label></th> <td><input type="text" name="email" id="frm-email" value="<?= $email ?>"/></td> </tr> <tr> <th><label for="frm-password-1"><span>* </span>Password</label></th> <td><input type="password" name="password-1" id="frm-password-1" value="<?= $password ?>"/></td> </tr> </tbody> </table> <p class="remember"><input type="checkbox" name="remember" value="1" id="frm_remember" /><label for="frm_remember">Remember me</label></p> <ul class="actions"> <li><input type="submit" value="Login" /></li> </ul> <p>Have you <a href="<?= WEB_ROOT ?>/password-reset.php">forgotten your password</a>?</p> </fieldset> </form> <? include DOC_ROOT . '/includes/footer.php'; ?> -- Our User Login Method in our class -- /** * Login the user * * Check the username and passord against the database. * If the user exists then return the User object. * * @param $email string Email * @param $password string Password * @return bool true on success, false on failure */ public static function login($email, $password) { $db = Connection::getInstance(); $results = $db->query(' SELECT * FROM `users` WHERE `live` = 1 AND `email` = \'' . $db->real_escape_string($email) . '\' AND `password` = \'' . md5($password) . '\'' ); if (!$results->num_rows) { return false; } else { $userData = $results->fetch_assoc(); // We already have a user data array with the OLD login time so // UPDATE user setting the last login to NOW Sneaky eh? $db->query(' UPDATE `users` SET `last_login` = NOW() WHERE `live` = 1 AND `approved` = 1 AND `email` = \'' . $db->real_escape_string($email) . '\' AND `password` = \'' . md5($password) . '\'' ); return new User($userData); } } As i mentioned if we run a var dump anywhere in the login function it displays this data on screen when the login fails but nothing appears when the login data is correct, almost as if the function is never run??? Any help would be really appreciated!!! Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 8, 2008 Share Posted July 8, 2008 1.) What version are you running with your development server? That might help us narrow down the problem. 2.) So you get a completely blank screen? Do you have display_errors turned on in your php.ini? If not, do so. Changing error_reporting to E_ALL might help us narrow down the problem too. Quote Link to comment Share on other sites More sharing options...
digital-overload Posted July 8, 2008 Author Share Posted July 8, 2008 Our Dev server is running on 5.1.2 (Linux ubuntu 2.6.15-26-386 ) We do not receive a blank screen the form just submits to its self and nothing happens, the session is not set, the user is not redirected its as if the submit form button was a link going to that page and the form is not being processed? If you need specific php server settings let me know what you need and i will dig them out. Thanks again for anyone taking a look at this, its driving us crazy!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.