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

  • Home
  • SEARCH
  • 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 7173053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:44:36+00:00 2026-05-28T15:44:36+00:00

Let say i’ve the follow files [index.php / admin.php / access.php] 1) File index.php

  • 0

Let say i’ve the follow files [index.php / admin.php / access.php]

1) File index.php is with login form

<form method="post" name="login" id="login" action="check.php">
Username : <input name="loginid" id="loginid" type="text">
Password : <input name="password" id="password" type="password">
</form>

it should send entries (user,pass) to file check.php so that check if the username and password is correct or not and i’d like to use this way

2) File check.php

At file check.php it should do the following function
– Check if the user,pass is correct
– If correct then create cookies or somehow
– If wrong or empty send me back to login.php

Let say here are my db informations

$sql= "select * from settings where admuser='$loginid' and admpass='$password'";
$result = mysql_query($sql) or die("query failed: $sql");

3) File access.php

This file should compare if i’ve logged or not so that if not send me back to login.php

4) File admin.php [ needs access.php to check if i’m logged or not]

<?php
include('access.php');
echo "balah blah blah";
?>

So can anyone please write this example as simple as possible

That example will helps me a lot to study it as study case
cause i’ve tried before but failed so i really do not know why and here was my last question Login not working after php updated but i found i need complate study case code that working.

thank you for helping

  • 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-28T15:44:37+00:00Added an answer on May 28, 2026 at 3:44 pm

    You can set a session on the filecheck.php page by using a simple if() loop.

    $loginid = mysql_real_escape_string(strip_tags($_POST['loginid']));
    $loginpass = mysql_real_escape_string(strip_tags($_POST['loginpass']));
    $sql = mysql_query("SELECT loginid, loginpass FROM settings WHERE loginid='$loginid' AND loginpass='$loginpass'");
    if(mysql_num_rows($sql) != 0){
          //create $_SESSION
       session_start();
       $_SESSION['id'] = $loginid;
    setcookie("id","id",time()+3600*24*30);
    }else{
             //the user doesn't match any of the ones in the database. Tell them to try another login}
    

    To keep the session active through the website just call the `session_start(); statement at the top of every webpage.
    By getting a match of username and password with the database and creating a $_SESSION[‘username’]; that only you could have created by using the user and password you have effectively logged in.

    To logout out you can use the session_destroy(); statement.

    One think to note about sessions is that the session will end when you close the webpage. The ideal login system will incorporate session and cookies. So that you can set a cookie as well as session when you login. When you close the webpage and later return to it the cookie will still exist, you can use the cookie to recreate the session. This stops the need for users to constantly have to login every time they return to the page.

    To reset the session['id'] you could do something like:

    if(!isset($_SESSION['id'])){
       if(isset($_COOKIE['id'])){
          $_SESSION['id'] = $_COOKIE['id'];
           echo '<p>Welcome back ' . $_SESSION['id'] . '</p>';
        }
    }elseif(isset($_SESSION['id'])){
          echo '<p>Welcome back ' . $_SESSION['id'] . '</p>';
    }else{
         echo '<p>Please login</p>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have a simple form with no required fields: <form action=index.jsp method=post>
Let say we have link as following for link as ****.com/index.php?id=4 the <?=$id?> is
Let say that I have a website with some information that could be access
Let say I'm on the page Home/Index and I want to go to the
Let say, I access to a server using ssh. In the same time, there
Let say I have a module which is the name Metro_Most_Viewed. The module configuration
Let say I am designing an interface, to return the name of the child
Let say I have a file that contains a serialized object by BinaryFomatter. Now
Let say that I have: proj1/app1 proj1/app1/templatetags/my_shared_tags.py proj1/app2 proj1/templates proj1/templates/app1/index.html proj1/templates/app2/index.html Now, how can
Let say I have this: <input id=album name=album type=checkbox value=1 /> <label for=album>Albums</label><br> <ul>

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.