What's new

Closed How to put database in html

Status
Not open for further replies.

Mickz_XVIII

Honorary Poster
Joined
May 16, 2017
Posts
389
Reaction
86
Points
242
mga paps! ang hirap i-connect ni xampp kay html :(

sino po willing magturo? yung libre lang po T.T salamat ng madami
 
step 1) install XAMPP (or extract, whatever)
step 2) run XAMPP after installation (make sure it's running 100% or yung kulay ng server icon ay GREEN)
step 3) access PHPMYADMIN (either from the server icon or sa browser You do not have permission to view the full content of this post. Log in or register now.)
step 3.a) if it's new setup, usually there's no password set.
step 4) then pag na-access mo na ang PHPMYADMIN ui, you can create a database.

Here's how to access database sa HTML page mo
1) gawa ka ng basic HTML page (index.php for example)
2) then add mo ito sa pinaka taas ng page mo (before <html>)

<?php
DEFINE("HOSTNAME","localhost");
DEFINE("USERNAME","rootOrUserNaGinawaMo");
DEFINE("PASSWORD","passwordKungMeron");
DEFINE("DATABASE","pangalanNgDatabaseNaGinawaMo");
$connection=mysqli_connect(HOSTNAME,USERNAME,PASSWORD,DATABASE);
if(!$connection){
die ("<html><script language='JavaScript'>alert('Ops! Cannot connect with the server at this time. Please try again later.'),history.go(-1)</script></html>");
} else {
echo "Yehey! naka connect na ako sa database!";
}
?>


......then start pulling out the data from your database and use and abuse them... :)
 
pa
step 1) install XAMPP (or extract, whatever)
step 2) run XAMPP after installation (make sure it's running 100% or yung kulay ng server icon ay GREEN)
step 3) access PHPMYADMIN (either from the server icon or sa browser You do not have permission to view the full content of this post. Log in or register now.)
step 3.a) if it's new setup, usually there's no password set.
step 4) then pag na-access mo na ang PHPMYADMIN ui, you can create a database.

Here's how to access database sa HTML page mo
1) gawa ka ng basic HTML page (index.php for example)
2) then add mo ito sa pinaka taas ng page mo (before <html>)

<?php
DEFINE("HOSTNAME","localhost");
DEFINE("USERNAME","rootOrUserNaGinawaMo");
DEFINE("PASSWORD","passwordKungMeron");
DEFINE("DATABASE","pangalanNgDatabaseNaGinawaMo");
$connection=mysqli_connect(HOSTNAME,USERNAME,PASSWORD,DATABASE);
if(!$connection){
die ("<html><script language='JavaScript'>alert('Ops! Cannot connect with the server at this time. Please try again later.'),history.go(-1)</script></html>");
} else {
echo "Yehey! naka connect na ako sa database!";
}
?>


......then start pulling out the data from your database and use and abuse them... :)

kahit saan po ba ang location ng php sa html?
 
You need to learn PHP first. Client-side lang yung HTML. Aralin mo muna kung pano mag set up ng local server e.g XAMPP, WAMP, etc. Study the basics here: You do not have permission to view the full content of this post. Log in or register now., You do not have permission to view the full content of this post. Log in or register now.
 
pa


kahit saan po ba ang location ng php sa html?
yes and no...

YES kung independent scope lang yung PHP (walang dinedependahan na mga server side initialization)
= halimbawa, gusto mo lang i-echo ang "hello world" o kaya gusto mo lang mag-compute ng simple math, etc.

NO kung nagre-rely ang scope sa database halimbawa or kaya mga stored procedures/functions
= halimbawa, ang php session kailangan nasa pinaka tuktok ng page para gumana, ang database access kailangan nasa tuktok din ng page usually (but not necessarily in some cases), stored functions, etc.
 
<?php
$servername = "localhost"; --> dpende sayo
$username = "root"; --->depende sayo
$password = ""; -->depende sayo
$dbname="hms";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connection Established Status 402";
?>

pag ka install mo ng xampp , punta ka sa htdocs ,
gawa ka ng folder ex:poop
dun mo lalagay ung mga php na file na gagawin mo ,
tas para ma open mo naman sya ,
* Open browser
*type "localhost/poop/"namengfile.php"
then boom
 
step 1) install XAMPP (or extract, whatever)
step 2) run XAMPP after installation (make sure it's running 100% or yung kulay ng server icon ay GREEN)
step 3) access PHPMYADMIN (either from the server icon or sa browser You do not have permission to view the full content of this post. Log in or register now.)
step 3.a) if it's new setup, usually there's no password set.
step 4) then pag na-access mo na ang PHPMYADMIN ui, you can create a database.

Here's how to access database sa HTML page mo
1) gawa ka ng basic HTML page (index.php for example)
2) then add mo ito sa pinaka taas ng page mo (before <html>)

<?php
DEFINE("HOSTNAME","localhost");
DEFINE("USERNAME","rootOrUserNaGinawaMo");
DEFINE("PASSWORD","passwordKungMeron");
DEFINE("DATABASE","pangalanNgDatabaseNaGinawaMo");
$connection=mysqli_connect(HOSTNAME,USERNAME,PASSWORD,DATABASE);
if(!$connection){
die ("<html><script language='JavaScript'>alert('Ops! Cannot connect with the server at this time. Please try again later.'),history.go(-1)</script></html>");
} else {
echo "Yehey! naka connect na ako sa database!";
}
?>


......then start pulling out the data from your database and use and abuse them... :)


Thankyou sir! I owe you my life and grades also ;))
 
Status
Not open for further replies.

Similar threads

Back
Top