我想使用php和html創建員工記錄。如何在用戶點擊該按鈕並創建mysql數據庫時在html中創建按鈕
我創建HTML表格,並在該表中的兩扣, 現在我想建立一個數據庫,員工信息存儲在它 但是當用戶點擊我與創建的HTML按鈕,我想Create Database
的名稱,我想添加與該按鈕的代碼,所以當用戶點擊它創建MySQL數據庫使用php 我創建了一個代碼,但它不起作用。
請幫助我使用PHP我如何實現這一功能和HTML我的代碼如下, 我使用WAMP服務器這個當我運行該文件沒有發生在服務器
<?php
$servername = "localhost";
$uername = "root";
$password = "";
if(isset ($_REQUEST["btncreatedatabase"]))
{
// create coonection
$conn = new mysql($servername, $username, $password)
// check connection
if($conn->connect_error){
die("Connection Falid : ". $conn->connect_error);
}
// create database
$sql = "CREATE DATABASE mydb";
if($conn->query($sql)===TRUE){
echo "Database created successfully";
}else{
echo "Error creating datdbase";
}
}
$conn->close();
?>
<!DOCKTYPE html>
<html>
<head>
</head>
<title>
Employee Data Base
</title>
<body>
<table width ="400" border = "1" cellpadding = "4"
cellspacing = "2" align = "center">
<tr height = "30" bgcolor = "#CE93D8">
<td colspan = "2" align = "center" <h2 color =
"#FF5733">Employee Form </h2>
</td>
</tr>
<tr align = "center">
<td >
<input type = "submit" name = "btncreatedatabase" id
="button1" value = "Create DataBase">
<input type = "submit" name = "btncreatetable" id
="button2" value = "Create Table">
</td>
</tr>
<form name = "Form Search" method = "post">
<tr bgcolor = "#E6E6FA">
<td align = "center" width="250"><input type="text"
name="txtSearch" id="textfield">
<input type = "submit" name = "btnsearch" id =
"button" value = "Search">
</td>
</tr>
</form>
</table>
</body>
</html>
interpunction是你的朋友!請使用它! – Jeff
這裏沒人能幫我解決這個問題嗎? – Umar