www.webdeveloper.com
Results 1 to 2 of 2

Thread: MySql Connection

  1. #1
    Join Date
    Dec 2011
    Posts
    39

    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>
    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);
        ?>
    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

    http://i43.tinypic.com/23vc5k5.jpg

    In other words

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

    Please help
    Last edited by tqmd1; 11-09-2013 at 02:01 AM.

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    729
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles