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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:35:15+00:00 2026-05-27T22:35:15+00:00

I am trying to create logins for users. I have an sql that inserts

  • 0

I am trying to create logins for users. I have an sql that inserts the information in a mysql database, but after that i don’t know how to actually start the login. As of now, I insert the information on join_action.php which then redirects to /index.php (below). Does session_start() on /index.php actually start the login? Becuase if so, it’s not working.

PHP (join_action.php):

$sql=mysql_query("INSERT INTO users VALUES ('','$name','$password','$email','$date','$time','$random','0','1','0')");
            $id=mysql_insert_id();
            $_SESSION['id'] = $id;



            header("Location: http://localhost/index.php");

HTML (index.php top):

 <?php session_start(); ?>
  • 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-27T22:35:16+00:00Added an answer on May 27, 2026 at 10:35 pm

    login.php (untested, but should give you the right idea)

    <?
       @session_start();
       if(isset($_POST['login'])){
        $name = addslashes({$_POST['login']});
        $password = addslashes({$_POST['password']});
        $res=mysql_query("SELECT * FROM users WHERE name = '{$name}' AND password = '{$password}'");
    
        if(mysql_num_rows($res)>0) {
          $_SESSION['loggedin'] = 1;
          $_SESSION['user'] = mysql_fetch_assoc($res);
         } else {
          $_SESSION['loggedin'] = 0;
          $_SESSION['user'] = null;
         }
        }
    
        if($_SESSION['loggedin']==1) {
    ?>
        Logged in! 
        <pre><? print_r($_SESSION['user]); ?></pre>
    <? } else { ?>
        Not logged in...<br>
        <form method='post' action='login.php'>
        <div>Login: <input type='text' name='login'></div>
        <div>Password: <input type='password' name='password'></div>
        <input type='submit' value='Log In'>
        </form>
    <? } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a website that will allow users to login with
I have created a java SE application that uses the mysql database using mysql
Im trying to create a iPhone Objective C login page using PHP/MySQL to authenticate.
First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I have a piece of code that creates an SQL Server Express 2008 in
I'm trying to create a very simple login for only one or two users,
Using CakePHP 1.3 I'm trying to save some data to a MySQL database. The
I have two problems. problem one: I am trying to create a registeration form
I'm trying to create a script for CI/deployment purposes, but am having problems. Unfortunately,

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.