如何使用wampserver创建数据库以及如何连接php页面


how to create database using wampserver and to connect with the php page

我已经为登录页面创建了网页前端设计,并将其保存为.php文件。

我甚至安装了wampserver。

给我一些如何连接mysql数据库wampserver和我的登录页面的想法。

是否可以在工具中使用wampserver中提供的数据库选项?

如果可能的话,我们如何连接到登录页面?请给出一些想法。。。

可以在Phpmyadmin中的wampserver中创建数据库,也可以创建表。

以下是连接到数据库的代码

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
//select a database to work with
$selected = mysql_select_db("database1",$dbhandle) // "database1" is the database name
 or die("Could not select database1");
//execute the SQL query and return records .. insert ur login info also
$result = mysql_query("SELECT uid  FROM login"); // "login" is table
if(mysql_num_rows($result) != 0){
$result1 = INSERT INTO login (id, name, password) VALUES
('".$_POST['id']."','".$_POST['name']."','".$_POST['password']."'); // The values which
                                                        //you entered in the login form
} else {
 echo "This login name already exists";
}
?>
This is the simple way to connect the database and insert the data into tables. But 
dont forget to create database and tables in phpmyadmin before inserting the data