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
https://forums.phpfreaks.com/topic/255233-headerlocation-not-working/
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.