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 7957087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:11:35+00:00 2026-06-04T04:11:35+00:00

Please I need your help with this log-in script. When a user registers, a

  • 0

Please I need your help with this log-in script. When a user registers, a column active in the database is set to zero (0), and an activation link is sent to the email they provided. When the activation link is clicked and if successful, their respective active column is set to 1.

But a correct combination of username and password only works when i click the submit button twice.

On the first click i get the following lines

Notice: Undefined index: remember in C:\wamp\www\church\login.php on line 37

Not Verified Yet

But when I click the second time the log-in works.

<?php
if (isset($_POST['submit'])) {
    $username = trim($_POST['username']);
    $username = strip_tags($_POST['username']);
    $username = htmlentities($_POST['username']);
    $username = stripslashes($_POST['username']);
    $username = mysql_real_escape_string($_POST['username']);
    $password = sha1($_POST['password']);

    if (isset($_POST['username']) && isset($_POST['password'])) {
        $query = mysql_query("SELECT username, password
                           FROM USERS
                           WHERE username = '$username'
                           AND password = '$password'") or die (mysql_error());

        $user = mysql_num_rows($query);
        if ($user == 1) {
            $row = mysql_fetch_assoc($query);
            if ($row['active'] == 1) {
                $_SESSION['logged_username'] = $username;
                if ($_POST['remember']) {
                    setcookie("CookieUser", $_SESSION['logged_username'], time() + 60 * 60 * 24 * 100, "/");
                    setcookie("CookiePass", $password, time() + 60 * 60 * 24 * 100, "/");

                    header('Location: http://127.0.0.1/church/index.php?id=1');
                }
            }
            if ($row['active'] !== 1) {
                echo "Not Verified Yet";
            }
        }
        else {
            echo "<div id='content' >";
            echo "<div class='OpenError' >";
            echo "Username & Password Combination Is Wrong";
            echo "</div>";
            echo "</div>";

        }
    }
}
?>
  • 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-04T04:11:36+00:00Added an answer on June 4, 2026 at 4:11 am

    The issue isn’t that you aren’t being logged in. It’s that your code does not die() after sending the redirect header and therefore continues executing the code on that page. Also, if the user does not select remember, nothing happens. To fix (the first issue), simply add die(); immediately after header("location: ...");.

    Why do I need die(); after header("location: ...");?

    The header() function sends a string (text) to the browser (or other program requesting the page). However, the server doesn’t know the difference between header("location: ..."); and header("somerandomthing: ...");, so it continues executing code until it either reaches the end of the script, an error, or the client disconnects. So, to prevent code execution from continuing, simply add die(); after every header("location: ..."); call.

    Update regarding not checking ‘remember’

    <?php
    if ($user == 1) {
            $row = mysql_fetch_assoc($query);
            if ($row['active'] == 1) {
                $_SESSION['logged_username'] = $username;
                if ($_POST['remember']) {
                    setcookie("CookieUser", $_SESSION['logged_username'], time() + 60 * 60 * 24 * 100, "/");
                    setcookie("CookiePass", $password, time() + 60 * 60 * 24 * 100, "/");
    
                }
                // Redirect even if not 'remembered'
                header('Location: http://127.0.0.1/church/index.php?id=1');
                die;
            }
            if ($row['active'] !== 1) {
                echo "Not Verified Yet";
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please i need your help with my script. I'm trying to post comments to
Please I need your help with my script. I'm trying to insert values into
I'm new to this ExpandableListView and I desperately need your help please. I'm using
Please I need your help with my script. I'm puting a link to old
Please i need your help with how to include INDEXES in my tables, i've
please i need you help with my script.. I'm trying to echo some content
I need your help on this guys!!!! During the upload of the files to
Hi, ive been dealing with this for some time now and need your help.
I need your help and please give me some advice. From programming pearls I
I need your help, i'm stacked on this project. When i run my applicaion

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.