Jump to content

header(Location: ) not working.


Andy11548

Recommended Posts

I've made a Login Script and I'm trying to make it re-direct me to the Homepage after the login is complete. However, it's doing nothing at all...

 

<?php
require('./includes/header.php');
require('./includes/functions.php');
?>
<div id="loginHolder">
   <div id="title"></div>
   <h2>Login</h2>
   <hr />
   <?php
      if(@$_POST['submit_login'])
      {
         echo '<div id="loginBox">';
         $username = protect($_POST['username']);
         $password = protect(encrypt($_POST['password']));
         
         $loginCheckQ = mysql_query("SELECT * FROM `users` WHERE `username`='".$username."'");
         $loginCheckF = mysql_fetch_assoc($loginCheckQ);
         
         $dbusername = $loginCheckF['username'];
         $dbpassword = $loginCheckF['password'];
         
         if($username == $dbusername && $password == $dbpassword)
         {
            $_SESSION['loggedUser']=$username;
            echo '<font color="green">You have successfully logged in as '.$username.'.</font>';
            header('location: index.php');
         } else {
            echo '<span>Incorrect Username or Password.</span>';
         }
         echo '</div>';
      }
   ?>
   <form action="login.php" method="POST" autocomplete="off">
      <table cellspacing="0" cellpadding="0">
         <tr>
            <td>Username: </td><td><input type="text" name="username" /></td>
         </tr>
         <tr>
            <td>Password: </td><td><input type="password" name="password" /></td>
         </tr>
         <tr>
            <td colspan="2"><input type="submit" value="Login" class="submit" name="submit_login" /></td>
         </tr>
      </table>
   </form>
</div>
<?php
require('./includes/footer.php');
?>

 

It works perfectly fine on Localhost, but when I upload it, it doesn't work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.