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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:17:51+00:00 2026-06-13T14:17:51+00:00

I am trying to make a simple PHP MySQL login page. I keep reading

  • 0

I am trying to make a simple PHP MySQL login page. I keep reading over the code and can’t see what I’m doing wrong. I’m testing with an e-mail and password that I’ve just looked at in the database as a test so I know it exists. When I click submit on the previous form, it just redirects me back to the same page and doesn’t log in (I know this because my header changes with the $_SESSION variables when it works; I know this because my registration page works but not the login once you register). Be aware too that upon registration they enter their first and last name which is why I’ve included it on the $_SESSION variables on session_start. Here’s the code (first the form and the then the checklogin.php page):

<!--THIS IS THE FORM FROM THE PAGE SIGN_IN.PHP-->
<form method="post" target="checklogin.php">
   <label for="email">EMAIL/USERNAME:</label>
   <input type="text" name="email" id="email">
   <label for="password">PASSWORD:</label>
   <input type="password" name="password" id="password">
   <br />
   <input type="submit" value="Let's Play!">
</form>

And this is the checklogin.php script that the form posts to:

<?php
$mysqli = mysqli_connect("mysql_name","login_id","password", "db_name");
if (!$mysqli)
  {
  die('Could not connect: ' . mysqli_error($mysqli));
  }

// username and password sent from form
//NEVER Remove the mysql_real_escape_string. Else there could be an Sql-Injection!
$email=$mysqli->real_escape_string($_POST['email']);
$password=$mysqli->real_escape_string($_POST['password']);

$sql="SELECT * FROM tbl_name WHERE email='$email' and password='$password'";
$result = $mysqli->query($sql);

if(is_object($result) && $result->num_rows == 1){
  // Register variables and redirect to file "profile.php"
  session_start();
  $_SESSION['firstname']=$_POST['firstname'];
  $_SESSION['lastname']=$_POST['lastname'];
  $_SESSION['email']=$_POST['email'];
  $_SESSION['password']=$_POST['password'];
  redirect('profile.php');
} else {
  echo "Wrong Username or Password";
}

?>

I’ve also tried this with header(‘location:profile.php’) but with the same results.

  • 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-13T14:17:52+00:00Added an answer on June 13, 2026 at 2:17 pm
    <form method="post" action="checklogin.php">
    

    The action attribute is for specifying the URL where you form will be posted. While the target attribute is for specifying where the URL should be loaded.

    If the action property is missing, it defaults to the current URL, this is why you are navigating to the same page when you submit the form.

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

Sidebar

Related Questions

Yo. I'm trying to make a simple login system in PHP and my problem
I'm trying to make a simple MySQL Admin thing with php and jQuery. I've
I'm trying to make a simple php script to find all src attributes from
I'm currently a student and I'm studying PHP, I'm trying to make a simple
I am trying to make an sample web app using php mysql, where if
I'm new to programming, trying to make simple cms: A index.php display all article
I am trying to make a simple query to a small MYSQL table, but
I am working with someone's else's code and am trying to make a simple
Ok, so I'm trying to make some simple code to display news articles from
this is a simple question. With PHP and MySQL, I'm trying to build a

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.