如何连接localhost-php

如何连接localhost-php,php,mysql,Php,Mysql,这是我要连接本地主机的HTML代码 <div class="design-w3l"> <div class="mail-form-agile"> <form action="#" method="post"> <input type="text" name="username" class="padding" placeholder="user name"

这是我要连接本地主机的HTML代码

<div class="design-w3l">
            <div class="mail-form-agile">
                <form action="#" method="post">
                    <input type="text"  name="username" class="padding" placeholder="user name" required=""/>
                    <input type="text" name="name" placeholder=" email..." required=""/>
                    <input type="password"  name="password" class="padding" placeholder="Password" required=""/>
                    <input type="password"  name="cnfpassword" class="padding" placeholder="Password" required=""/>
                <input type="submit" value="submit">
                </form>
            </div>
          <div class="clear"> </div>
        </div>

如何连接本地主机phpmyadmin(php)?




@Dipakchavdav您忘记了mysql中的i_connect@ghost你的问题是unclarcheck@Dipakchavdav你忘了mysql中的i_connect@ghost你的问题是不明确的,检查这个!在mysqli扩展上使用PDO。这个!通过mysqli扩展使用PDO。
<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "yourDatabase";

//connect to database
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);


//create table
$sql = "CREATE TABLE TableName (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    column1 VARCHAR(30) NOT NULL,
    column2 VARCHAR(30) NOT NULL,
    column3 VARCHAR(30) NOT NULL,
    reg_date TIMESTAMP
)";

// execute
$conn->exec($sql);



// insert data
$sql = "INSERT INTO TableName (column1, column2, column3)
VALUES ('aaaa', 'bbbb', 'cccc')";

//execute
$conn->exec($sql);