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

1
  • 1
    You cannot connect to a database by using a .html file Commented Feb 23, 2013 at 14:10

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
Yes,he can by placing this block inside an php file, and just in each php file use #Require(connection.php);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.