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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:51:46+00:00 2026-05-30T23:51:46+00:00

I have a mysql set up and it is full working however there is

  • 0

I have a mysql set up and it is full working however there is one thing more I would like to do. Is there a way that when a user enters their username and password and clicks login in it will store their browser and browser version in in a new column in mysql?

  • 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-30T23:51:48+00:00Added an answer on May 30, 2026 at 11:51 pm

    I’m assuming the server-side technology is php since you’re mentioning mysql. If that’s incorrect, let me know and I’ll correct the following.

    <?php
      $username = $_POST['username'];
      $password = $_POST['password'];
      $agent = $_SERVER['HTTP_USER_AGENT'];
    
      $db = new PDO(...);
      $query = $db->prepare("SELECT * FROM users WHERE username = ? AND password = ?");
      if (($result = $query->execute(array($username, MD5($password)))) !== false){
        // login user
        $log = $db->prepare("INSERT INTO log (username, agent) VALUES (?, ?)");
        $log->execute(array($username, $agent));
      }
    

    You can use $_SERVER['HTTP_USER_AGENT'] to get their browser (and parse the value to determine the actual agent (e.g. IE, Firefox, Opera, etc.)) then save that information back to the database.


    Update

    First, you need to add a new column to the user table to allow for an additional piece of information (the browser):

    ALTER TABLE   user
    ADD COLUMN    useragent VARCHAR(100);
    

    This will need to be performed directly on the database, so however you added the user table intially, you’ll need to execute the above code (phpMyAdmin I’m guessing?)

    Next you need to modify your UPDATE call to also include the useragent:

    $sql = "UPDATE  user
            SET     logindate = NOW(),
                    useragent = '" . mysql_real_escape_string($_SERVER['HTTP_USER_AGENT']) . "'
            WHERE   username = '" . $input_username . "'";
    mysql_query($sql) or die('Error in SQL: ' . mysql_error());
    

    And that should be all there is to it.

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

Sidebar

Related Questions

I need to have MySQL query like this one: UPDATE table_name SET 1 =
I have a MYSQL stored procedure SP1() that returns a result set. I want
I have a mysql table that is full of text that is latin encoded.
How can I NOT have the full result set from mysql copied into memory
I have a table in my MySQL ( InnoDB ) full with user items.
I have a result set that is the result of a MySQL UNION query.
I have a mysql databased with many tables and fields. I would like to
I have a mysql database set as utf-8, and csv data set as utf-8,
I have a mysql table field set as time type which stores data in
I have a DATE datatype mysql column in a table. I want to set

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.