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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:52:30+00:00 2026-06-17T16:52:30+00:00

Possible Duplicate: How to safely store a password inside PHP code? So this is

  • 0

Possible Duplicate:
How to safely store a password inside PHP code?

So this is the scenario
I have an C# program.
It will send the Serial Number to my website. (eg: http://www.example.com/LicenseCheck.php)
lets say it sent 1234-1234-1234 as serial.

The licenseCheck.php will then connect to my mysql:

<?php
$username = "your_name";
$password = "your_password";
$hostname = "localhost"; 

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
?>

then it will do a “select” from valid serial table and if the license exist in the table then that means it’s a valid serial.

Basically, what im trying to find what would be a good way to approach this.
I’m mostly worried about where to store the “Username”, “Password”. basically I will only have one user who will only have the read permission.

I would like to hide the username and password as best as possible and would like to approach this in a secure way.

What do I mean by “Secure”? Just a way that would keep unauthorized users from getting into my my databasae.

Thanks for all the help.

  • 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-17T16:52:31+00:00Added an answer on June 17, 2026 at 4:52 pm

    mysql function are no longer to be used. I’m going to give you a mysqli procedural approach to your solution. I’m also going to include a secure method of saving your password.

    basic mysqli connection and querying:

    $queryString = "SELECT COUNT(*) FROM table WHERE userName = ? AND password=?";//not the question marks
    //the question marks are used to bind our parameters/variables so the query string cannot be adjusted I believe? 
    $DBH=mysqli_connect('local','user','pass');
    mysqli_select_db($DBH,'database');
    $query = mysqli_prepare($DBH,$queryString);
    mysqli_bind_param($query,'ss',$username,$passwordHASH);//the second parameter declares the datatypes 
    mysqli_execute($query);
    //mysqli_bind_result($results); ||not needed in this situation but this is how you'd get results from the database
    if(mysqli_fetch($query)){ //adding  && $results = 1 would insure there is only one record
        //username and password match
    }
    else{
        //error builder etc
    }
    

    Now for your passwords I’d recommend using a hmac_hash() to provide protection. When inserting your passwords to your database insure that they are hmac_hash()ed to that when you come to querying your database these are protected as such.

    $passwordHASH = hash_hmac('sha512',$hashThis, '&R4nD0m^');
    

    So basically your query/fetch will return true if COUNT(*) returns 1 if username and password is equal to $username and $passwordHASH.

    BUT having said all that couldn’t you use #include <mysql.h> the mysql library in C#?

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

Sidebar

Related Questions

Possible Duplicate: Can php variable hold harmfull code safely? Let's say I have array
Possible Duplicate: STL vector and thread-safety If I have this piece of code: std::vector<std::vector<double>>
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: How can a Java program use files inside the .jar for read
Possible Duplicate: PHP 2-way encryption: I need to store passwords that can be retrieved
Possible Duplicate: fork in multi-threaded program If I have an application which employs fork()
Possible Duplicate: Variable doesn’t get returned from AJAX function I have this function: function
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: Can main function call itself in C++? I found this problem very

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.