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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:48:12+00:00 2026-05-30T02:48:12+00:00

I am attempting to learn php and I am at a really early stage!

  • 0

I am attempting to learn php and I am at a really early stage!

What I am trying to do is hide the div that contains a login form when the user is logged in, I have managed to successfully create the database connection and login form etc in order to allow a user to stay logged in and a session to stay open but not sure the next step to hide the .

I know I need an if statement but not sure where to go!

I wont include the whole code as the html is enormous but here is the form I want to hide:

    <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>

not sure what elso you would need to see but here is the php in the page:

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

That is before the tags then before the form I have:

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

Would you need the login check php code and the database connection php code to help advise?

  • 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-30T02:48:14+00:00Added an answer on May 30, 2026 at 2:48 am

    Say you have a variable called $logged_in. Then you could enable that form depending on whether the user is logged in or not like this. Using the special control syntax for templates:

    <?php if (!$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>
    <?php endif; ?>
    

    As for your PHP code, I’m not sure what the meaning of that $_GET['showerror'] is, but it seems to me like you are somehow performing the authentication in Javascript and then just redirecting to your PHP or something. Note that one could easily just call your script like logincheck.php?errorcode=0 and fool it into thinking that one just logged in correctly.

    You should perform the authentication inside your PHP code. If login was successful, just create a session and mark it as authenticated in the $_SESSION variable, it will then be persistent across page loads.

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

Sidebar

Related Questions

I'm trying to learn python and I'm attempting a hangman game. But when I
Currently, I'm trying to learn Javascript by writing my code in Gedit then attempting
I'm attempting to learn how to read in an access/zip file that has an
I am trying to create a website that will allow users to login with
I am attempting to learn the PyMT library and am trying to implement a
I am working on a class that utilises a UdpClient, and attempting to learn/utilise
I'm trying to learn php and step one is getting php working in some
I am attempting to learn debugging in x86 assembly and am trying to debug
I've been attempting to learn C in my spare time, and other languages (C#,
I'm attempting to learn a little more about handling sockets and network connections in

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.