/    Sign up×
Community /Pin to ProfileBookmark

MySql Connection

Dear Sir,

HTML file has following codes

[code]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Connection Checking</title>
</head>
<body>
<center>
<h1>Connection Checker</h1>
<fieldset style=width:300px;background-color:#E0FFFF>
<legend sytle=font-size:12;>Click Connect</legend>
<form name=”form1″ action=”connect.php” method=”post”>
<table>
<tr><td></td><td align=”center”><input type=”submit” name=”button1″ value=”Connect”>
</td></tr>
</table>
</form>
</fieldset>
</center>
</body>
</html>
[/code]

and Connect.php has folllowing codes

[code]

<?php
// Connection variables
$host=”localhost”;
$username=”root”;
$password=””;
$db_name=”asia”;

// Connect to database
$con=mysqli_connect(“$host”, “$username”, “$password”);

// Connect result
if(!$con){
die(‘Error Connecting to Database: ‘ . mysqli_error());
}
else
{
echo “Connected” . mysqli_error($con);
}
//close the connection
//mysql_close($con);
?>

[/code]

Both files have no problems and works fine.

But I need following modifications:

When connection is established then this line trigs from connect.php

echo “Connected” . mysqli_error($con);

While standing on html page, I want to show a messagebox like this

[IMG]http://i43.tinypic.com/23vc5k5.jpg[/IMG]

In other words

When I press Connect button then connection result must appear on same page not on other page.

Please help

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmNov 10.2013 — What "other" page?

Your html is going to call your "connect.php" script. That is going to run and display your message on a blank screen. That is all. Now to have that message displayed differently you have to put some html in your connect script to display your webpage and maybe make a <div with some border and coloring and a title bar in a div inside your div. Then display a php variable that you create instead of using 'echo' to send your message. Some CSS will come in handy to design your box.

Or you could use javascript, but that is another forum.
×

Success!

Help @tqmd1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...