Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8119261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:45:08+00:00 2026-06-06T04:45:08+00:00

Okay this is definitley an easy question and a stupid one but since I

  • 0

Okay this is definitley an easy question and a stupid one but since I have been developing on localhost i didn’t even realise it was a problem. The header to redirect to members page in the loginscript is not working because it is positioned incorrectly. This did not cause a problem on wamp but is on the live server. The script is included in an html file for reasons too long to tell here. Nothing is echoed in the script until something goes wrong but then the script is stopped. Where should i put the redirect header?

Here is the login script:

<?php 

// Connects to your Database 

include ("database.php");


 //Checks if there is a login cookie

 if(isset($_SESSION['username']))


 //if there is, it logs you in and directes you to the members page

 {  
    echo '<div id="probwarn"><t1><b>You are already logged in! You do not need to do it again.</b></t1></div>';

}


 //if the login form is submitted 

 if (isset($_POST['submit'])) { // if form has been submitted

$flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload.

 // makes sure they filled it in

if(!$_POST['username'] | !$_POST['pass']) {

    echo('<div id="probwarn"><t1>You did not fill in a required field.</t1></div>');
$flag = $flag + 1;
    }

// checks it against the database





    $pass = htmlspecialchars(mysql_real_escape_string($_POST['pass']));
    $username = htmlspecialchars(mysql_real_escape_string($_POST['username']));




   $check = mysql_query("SELECT * FROM members WHERE username = '".$username."'")or die(mysql_error());



 //Gives error if user dosen't exist

 $check2 = mysql_num_rows($check);

 if ($check2 == 0) {
if($flag == 0) {
    echo('<div id="probwarn"><t1>You must <a href="register.html">    <b>register</b></a> first.</t1></div>') ;


            }
    $flag = $flag + 1;
    }           

 $check = mysql_query("SELECT * FROM members WHERE username = '".$username."'")or     die(mysql_error());
 $pass = htmlspecialchars(mysql_real_escape_string($_POST['pass']));
    $username = htmlspecialchars(mysql_real_escape_string($_POST['username']));

 while($info = mysql_fetch_array( $check ))     

 {

 $_POST['pass'] = stripslashes($_POST['pass']);

$info['password'] = stripslashes($info['password']);

$_POST['pass'] = md5($_POST['pass']);



 //gives error if the password is wrong

if ($_POST['pass'] != $info['password']) {
 if($flag == 0) {
    echo('<div id="probwarn"><t1>Incorrect password, please try again.</t1>    </div>');
$flag ++;
     } }

   }        





 // if login is ok then we add a cookie 
 if($flag == 0) {
 $pass = htmlspecialchars(mysql_real_escape_string($_POST['pass']));
 $username = htmlspecialchars(mysql_real_escape_string($_POST['username']));



 $_SESSION['username']=$username;
 $_SESSION['password']=$pass;

 //then redirect them to the members area
//THIS IS THE HEADER 
 header("Location: ../members.html");





 } 

 } 

 else 





 // if they are not logged in 

 ?> 
 LOGIN FORM IS USUALLY HERE
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:45:09+00:00Added an answer on June 6, 2026 at 4:45 am

    You forgot to exit after setting a Location header. Unless you know exactly what you’re doing, you should ALWAYS put exit (or die()) after a Location header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay this may be a simple question but I have yet to come with
Okay this is definitely a n00b question but here goes. The way I understand
Okay this question is very simple: I have a facebook page, and a website.
Okay this one may be a bit out from left field, but I'm going
1. Okay this is probably lame question, but I haven't found good result searching
Okay this may sound a bit weird but it is what I have to
Okay this is a homework question, and I just don't have a clue how
Okay this is a revised question from earlier today, I have included code to
Disclaimer: I have looked through this question and this question but they both got
Okay this may seem too simple of a question but I've wasted enough time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.