-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql_connect_install.php
64 lines (49 loc) · 1.23 KB
/
mysql_connect_install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
session_start();
if (!session_id()) {
header ("location: install.php");
}
$hostname=$_SESSION['host'];
$username=$_SESSION['user'];
$password=$_SESSION['pass'];
?>
<!DOCTYPE html>
<head><title>Database setup</title></head>
<body>
<?php
$db_data = fopen ("db_data.txt", "w");
if($hostname != '' || $hostname != NULL){
$db_data = fopen ("db_data.txt", "w");
fwrite($db_data, '///host: ' . $hostname . '///User: ' . $username . '///Pass: ' . $password);
if (isset($hostname) && isset($username) && isset($password))
{
$mysqlconnect = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL";
}
} else {
echo "You must specify your host, username and password";
}
?>
<div class="form">
<p>Please enter the name of MySQL database:</p>
<form action="mysql_connect_install.php" method="post">
Database name: <input type="text" name="db_name">
<br>
<br>
<br>
<input type="submit" name="submit2">
<?php
if (isset($_POST['submit2'])) {
$db_name = $_POST['db_name'];
$create_db = "CREATE DATABASE {$db_name}";
if (mysql_query($create_db)) {
echo "Database created sucessfully!";
}else{
echo "Something went wrong!";
}
}
?>
</div>
</body>
</html>