|
8 | 8 | */
|
9 | 9 | require_once('functions.php');
|
10 | 10 | if(isset($_POST['host'])) {
|
11 |
| - // create file 'dbinfo.php' |
12 |
| - $fp = fopen('dbinfo.php','w'); |
13 |
| - $l1 = '$host="'.$_POST['host'].'";'; |
14 |
| - $l2 = '$user="'.$_POST['username'].'";'; |
15 |
| - $l3 = '$password="'.$_POST['password'].'";'; |
16 |
| - $l4 = '$database="'.$_POST['name'].'";'; |
17 |
| - $l5 = '$compilerhost="'.$_POST['chost'].'";'; |
18 |
| - $l6 = '$compilerport='.$_POST['cport'].';'; |
19 |
| - fwrite($fp, "<?php\n$l1\n$l2\n$l3\n$l4\n$l5\n$l6\n?>"); |
20 |
| - fclose($fp); |
21 |
| - include('dbinfo.php'); |
| 11 | + |
| 12 | + |
22 | 13 | // connect to the MySQL server
|
23 |
| - mysql_connect($host,$user,$password); |
| 14 | + $link=mysql_connect($_POST['host'],$_POST['username'],$_POST['password']); |
| 15 | + if (!$link) { |
| 16 | + die('Could not connect:' ); |
| 17 | + } |
| 18 | + else { |
| 19 | + // create file 'dbinfo.php' |
| 20 | + $fp = fopen('dbinfo.php','w'); |
| 21 | + $l1 = '$host="'.$_POST['host'].'";'; |
| 22 | + $l2 = '$user="'.$_POST['username'].'";'; |
| 23 | + $l3 = '$password="'.$_POST['password'].'";'; |
| 24 | + $l4 = '$database="'.$_POST['name'].'";'; |
| 25 | + $l5 = '$compilerhost="'.$_POST['chost'].'";'; |
| 26 | + $l6 = '$compilerport='.$_POST['cport'].';'; |
| 27 | + fwrite($fp, "<?php\n$l1\n$l2\n$l3\n$l4\n$l5\n$l6\n?>"); |
| 28 | + fclose($fp); |
| 29 | + include('dbinfo.php'); |
24 | 30 | // create the database
|
25 | 31 | mysql_query("CREATE DATABASE $database");
|
26 | 32 | mysql_select_db($database) or die('Error connecting to database.');
|
|
81 | 87 | mysql_query($sql);
|
82 | 88 | header("Location: install.php?installed=1");
|
83 | 89 | }
|
| 90 | + } |
84 | 91 | ?>
|
85 | 92 | <!DOCTYPE html>
|
86 | 93 | <html lang="en"><head>
|
|
0 commit comments