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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:25:56+00:00 2026-06-07T13:25:56+00:00

I have a form that users can fill out, and the data will be

  • 0

I have a form that users can fill out, and the data will be stored into a MySQL database using PHP. The connection to the Apache server is encrypted through HTTPS, and I would like to encrypt the connection to the MySQL database. Both Apache and MySQL are on the same server machine.

I digged around the Interweb and Stunnel seems to be what I need. OpenSSL and SSL are supported and activated on the server, since the we are given the option of using the standard port and a stunnel port to connect to the MySQL server. However, all the articles I found online deal with using Stunnel to connect a MySQL client to an external MySQL Server, but not how to use PHP to connect to a local MySQL server. Am I right to assume that just because the form is transmitted through https, it doesn’t mean that the connection to the database is also encrypted?

The PHP code I use to connect to MySQL is like this:

$mysqli = new mysqli("ip","user", "password", "database", "standardport");

This works fine using the standardport. However, if I change it to a Stunnel Port, I get a connection time-out error. Clearly I’m missing something; any help and advice is appreciated! Thanks!

  • 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-07T13:25:58+00:00Added an answer on June 7, 2026 at 1:25 pm

    You’ve already stated that you use an HTTPS connection to encrypt traffic between the clients browser and your webserver, and that the webserver and MySQL instance are on the same machine.

    Assmuning the HTTPS connection is secure, this should be all you need to protect your data over public networks, and using a secure tunnel for a connection that is only present on the local machine simply adds an unnecessary layer of complexity.

    Consider the following examples.


    The first is how the connection looks without a secure tunnel.

    browser <--HTTPS--> [ webserver <--> mysql ]

    So in this scenario, the the connection between the webserver and mysql is unencrypted. Someone who has access to the machine (depending on permissions) will be able to observe all traffic between the webserver and/or read the physical databases from disk themselves.


    Now, with a secure tunnel

    [ webserver <--> stunnel <--ENCRYPTED--> stunnel <--> mysql ]

    I hope you can see that the connections between the webserver and one secure tunnel endpoint, and the connection between mysql and the other endpoint are both unencrypted. In this scenario, exactly the same as before, someone with access to the machine could potentially see all traffic and read the databases from disk.

    No additional security has been achieved.


    Lastly

    [ webserver <--> stunnel ] <--ENCRYPTED--> [ stunnel <--> mysql ]

    When you are using two separate servers, then the local traffic is still unencrypted, however stunnel secures the stream between the two machines. Someone with local access to the machines may still be able to observe traffic and read data, however someone observing network traffic between servers will not.


    A solution?

    All that said, if you really want to encrypt the traffic between PHP and MySQL, even on the same machine, a slightly better solution exists than using stunnel.

    MySQL supports SSL natively, as does PHP when both are compiled with SSL support. (Your installations may already be configured this way, it’s up to you to check them)

    The MySQL manual details how to configure your MySQL server with SSL support and PHP provides the function mysqli_ssl_set

    Using this combination, you can natively encrypt the connection between PHP and the mysql server.

    [ webserver <--ENCRYPTYED --> mysql ]

    However someone with access to the machine may still be able to read the unencrypted database from disk, and may be able to observe the memory of running processes.

    You are quite right, the internet is a dangerous place, and proper security is essential. If your server itself and the data it contains are not secure, all is lost, no matter what precautions you take securing how the data enters and leaves it.

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

Sidebar

Related Questions

(Using MySQL and PHP) I have a search form that will allow my users
i have a form that users can fill out and i need the users
I have a web form that users can fill out and that content fills
On my site, I have a form that users fill out to become a
Okay all, I have a form that I want users to fill out. When
I have a form that I have users fill out and then it gets
Okay, next PHPExcel question. I have an HTML form that users fill out and
I have a fairly simple website where users can fill out a form describing
I've got a web where logged in users can fill out a form to
I have a form that a user would fill out while creating a ticket

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.