0

Ok so I did a search to see if there other posts that explain this completely...

Well i'm here now :)


SCENARIO:

  1. I want to connect to your mysql database via html.
  2. I DO NOT want to set the parameters explicitly everytime I wish to perform a query
  3. I have multiple users and (ofcourse) you want their login details available throughout the application

Craig Wayne
  • 4,499
  • 4
  • 35
  • 50

1 Answers1

1
  1. You'll need PHP to make connection inside connection.php file

    <?php
    
    $conn= mysqli_connect("localhost","ID","Password","Database_name");
    

    Then in each file you put require('connection.php'); and there is no way than that for making a connection to MySQL database.

  2. Set queries as functions and send the thing you want to search for as a variable.

  3. Use $_Session or $_Cookie once the user enter his email/password.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Mina Roger
  • 109
  • 4
  • Mina, he said he didn't want to explicitly make the connection, which is exactly what your answer is doing. Is there any way he can make the connection without having to make that block every time? – Sometowngeek Dec 14 '19 at 14:39
  • 1
    Yes,he can by placing this block inside an php file, and just in each php file use #Require(connection.php); – Mina Roger Dec 21 '19 at 11:43