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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:44:23+00:00 2026-05-24T20:44:23+00:00

Would this login function be secure, I put the url data straight into the

  • 0

Would this login function be secure, I put the url data straight into the function, but would this be unsafe? Could this be injected, I know it has no SQL, but is it venerable?

if ($_SERVER["REQUEST_METHOD"] == "POST") {    
    $login = check_login($_POST['emailusername'], $_POST['password']);
    if ($login) {
        // Registration Success
       header("location: /");
    } else {
        // Registration Failed
        echo 'Username / password wrong';
    }
}

function:

// CHECK LOGIN SCRIPT
   function check_login($emailusername, $password) 
    {

$host = 'localhost';
$port = 3306; // This is the default port for MySQL
$database = 'example';
$username1 = 'root';
$password1 = 'root';

$dsn = "mysql:host=$host;port=$port;dbname=$database";
$db = new PDO($dsn, $username1, $password1);

                $password = md5($password);


$statement = $db->prepare('SELECT uid FROM users WHERE (email = ? or username = ?) and password = ?');
$statement->execute(array($emailusername, $emailusername, $password));

if ($result = $statement->fetchObject()) {
    $_SESSION['login'] = true;
    $_SESSION['uid'] = $result->uid;
    return TRUE;
}else{
    return FALSE;
}    }
  • 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-24T20:44:24+00:00Added an answer on May 24, 2026 at 8:44 pm

    I don’t see a reason why it would be unsecure, but I’d suggest you to follow authentication best practices though.

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

Sidebar

Related Questions

I'm loading a simple page using: $.get('../admin/login.php', function(data) { $('#box-contents').html(data); }); Now, on this
For a login system in php would this be a suitable outline of how
Maybe my logic is not restful or know if this is how you would
Would this work on all platforms? i know windows does \r\n, and remember hearing
I have read that you can do it, but would this really improve performance
So I've got this simple login function that is trying to match email address
As part of my Selenium test for a login function, I would like to
I'm learning jQuery and this is my code so far: <script type=text/javascript> $(document).ready(function(){ $('#login').click(function(){
Is there any reason something like this would not work? This is the logic
How would I usually represent this business logic in a graph? A is true

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.