How to connect MySQL Database?

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

How to connect MySQL Database?

Postby krrahman » 07. September 2014 10:25

Hello, I am new in web designing. Here, I want to know 'how i can connect a MySQL database from a html page'. Actually I have a simple web page designed through html and css, a login form is there. I want users will have to put their information in the form and when they click on submit button, it will store in the data table.

If any body help me by giving a step by step solution. Thank you
krrahman
 
Posts: 2
Joined: 24. June 2014 07:03
Location: Dhaka
Operating System: windows7

Re: How to connect MySQL Database?

Postby Altrea » 07. September 2014 11:21

Hi,

You cannot do it with HTML alone. HTML is just a Markup language.
You need to send the form to a php file which do the database connect and insert the data.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: How to connect MySQL Database?

Postby krrahman » 07. September 2014 11:40

Altrea wrote:Hi,

You cannot do it with HTML alone. HTML is just a Markup language.
You need to send the form to a php file which do the database connect and insert the data.

best wishes,
Altrea


Thanks. Could you please provide an example ?
krrahman
 
Posts: 2
Joined: 24. June 2014 07:03
Location: Dhaka
Operating System: windows7

Re: How to connect MySQL Database?

Postby Altrea » 07. September 2014 11:43

Suche in der Suchmaschine deines Vertrauens mal nach "PHP mysqli tutorial" oder "PHP PDO tutorial"
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: How to connect MySQL Database?

Postby Nobbie » 07. September 2014 13:45

krrahman wrote:Could you please provide an example ?


CGI Programming including PHP Programming (incl. storing and retrieving Data into a SQL Database) is a very complex subject, you cannot simply provide an example and thats it. You should look for tutorials and or literatur about "HTML & CGI and PHP, including MySQL Programming" or similar.

You have to learn how forms are working, what is a HTTP Request (especially the meaning of a POST request), how does HTTP work (how does a webserver like Apache communicate with a client browser), how does CGI work (how to transfer data via forms and how to process the incoming data on the server, which programming language to use - here it is PHP, but there is also Python, Perl etc.), how does an SQL Database work, what is a SELECT Statement, what is a table, how does PHP communicate with an SQL Server, and and and and and and ... you may have to learn quite a lot in the next months.
Nobbie
 
Posts: 8762
Joined: 09. March 2008 13:04

Re: How to connect MySQL Database?

Postby munnibhai » 12. October 2014 15:21

What you want to do is use PHP, this is the way a database can be connected using mySQL..

I can give you a basic example of this,

Assuming you have created a database in XAMPP PHPMyAdmin, with a user and password assigned to it, here how you would do it.

Code: Select all
<?php
$dbUser= "DATABASE_USERNAME_HERE";
$dbPass = "DATABASE_PASS_HERE";
$dbName = "DATABASE_NAME_HERE";
$dbHost = "YOUR_HOSTNAME"; // Usually it is 'localhost'

$con = mysql_connect($dbHost, $dbUser, $dbPass);
if(!$con){
 die(mysql_error());
} else {
 mysql_select_db($dbName, $con);
 echo  $dbName . " has been connected";
}
?>


The above example is given in mySQL_* which is now depreciated, so you should switch to PDO which is faster, secure and convinient.
munnibhai
 
Posts: 1
Joined: 12. October 2014 15:14
Operating System: Windows 7


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 3 guests