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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:47:55+00:00 2026-05-30T03:47:55+00:00

I asked a very similar question and I approved an answer as I thought

  • 0

I asked a very similar question and I approved an answer as I thought it had done the job but it hasnt! for the life of me I can’t understand why this wont work! I want a form in html to dissapear when the user is logged in! Heres my code so far! (I wont display all code as the html is loooong but I think this is relevent, please bear in mind I am at the early beginner stage of php):

I have this at the top of my page:

    <?php
if (isset($_GET['showerror']))
$errorcode = $_GET['showerror'];
else
$errorcode = 0;
?>

Then the code to try and hide the form and to display an error if the username/password is incorrect:

<?php
if ($errorcode == 1)
    {
    echo "<h3>Your login has failed. Try again</h3>";
    }
?>

<?php
session_start();

if (!isset($_SESSION['is_logged_in'])) {
?>

<form id="login" name="login" action="logincheck.php" method="post">
            User Name: 
            <input type="text" name="username"></input>
            Password: 
            <input type="password" name="password"></input>
            <input type="submit" name="submit" value="login"></input>
            <a href="javascript: void(0)" onclick="popup('register.html')" > (Register)</a>
            <br /><br /><br />
        </form>
<?
}
?>

The next code is what I wrote to check if the login credentials are correct, and to turn us back to the index.html page, I assign a value to errorcode so I can display the error message if the credentials are wrong and I assign a value to is_logged_in to hide the form if they are correct. In both instances we are turned back to index.html but hopefully either with a form on display and an eroor message, or no form and no message: (dbconn.php is my connection to the mysql database)

    <?php
session_start();
require "dbconn.php";

$username = $_POST['username'];
$password = $_POST['password'];

$sql = "SELECT * FROM person WHERE name ='".$username."' AND password='".$password."'";

$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_array( $result );

if ($row != null)
    {
    $_SESSION['username'] = $row['name'];
        header("Location: index.html?is_logged_in=1?");
    exit();
    }
 else
    {
    header("Location: index.html?showerror=1");
     exit();
    }
?>

but the problem is that neither of the two outcomes, I get no error message and I get no hidden form, because nothing is happening it is difficult for me to gauge where I am going wrong!

Thank you sooooo much for any help… I spent ages setting up xampp properly and got ready to learn lots but I have been stuck here for a good few hours now!

EDIT: still getting to grips with this code editing! didnt display some of code but I think its done now!

  • 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-05-30T03:47:57+00:00Added an answer on May 30, 2026 at 3:47 am

    You don’t set the session variable is_logged_in, put

    $_SESSION["is_logged_in"] = 1;
    

    into the login file (between the brackets if $row != null)

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

Sidebar

Related Questions

I asked a very similar question here but since it is such a fundamental
I had asked a question very much similar to this in the thread: https://stackoverflow.com/questions/11259474/store-the-numericals-in-char-array-into-an-integer-variable-in-vc
This is very similar to a question I asked the other day but my
This is very similar to a question I asked the other day but my
I have asked a similar question before, but didn't get very good results. I've
I'd asked a very similar question earlier , but the project scope is quickly
I've asked a very similar question before, but this time is not about VB
A very similar question, but not exact to those asked frequently; my project has
I'm afraid very similar question has been asked already here , but for some
I've already asked a very similar question but that was using javascript/php - i've

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.