Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    116
    Thanks
    19
    Thanked 1 Time in 1 Post

    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 '<script type="text/javascript">alert("Connected"). mysqli_error($con);</script>'; 
        }
        //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 '<script type="text/javascript">alert("Connected"). mysqli_error($con);</script>';

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





    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 08:20 AM. Reason: edit


 

Posting Permissions

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