¿Como cambio esto para que me pida el nombre de la base de datos que ya tengo creada en lugar de tener que elegirla en una lista desplegable?
Codigo del paso 2:
Código PHP:
} else if ($step == 2) {
echo "
<table class='topic'>
<tr>
<td>SimpleNews Database</td>
</tr>
</table>";
// MySQL vars from step 1
$username = $_POST['username'];
$password = $_POST['password'];
$hostname = $_POST['hostname'];
// Process Step 2
if (!empty($submit)) {
$sql_db = $_POST['dblist']; // Existing DQ
$newdb = $_POST['newdb']; // New DB
// Check if it's going to be a new or existing database
if (!empty($sql_db)) {
$database = $sql_db;
} else {
$database = $newdb;
$sql = mysql_connect($hostname,$username,$password);
mysql_query("CREATE DATABASE $database");
echo "<p>SimpleNews database was created succsesfully!</p>";
}
// dbconnect.php template
$config = "<?phpn
// *************************************************
// Set User Access
// *************************************************\n
$hostname = "$hostname\";
\$username = \"$username\";
\$password = \"$password\";
\$database = \"$database\";
// *************************************************
// Database Connection
// *************************************************\n
\$connection = mysql_connect(\$hostname,\$username,\$password) or die (mysql_error()); \n
\$database = mysql_select_db(\$database,\$connection) or die (mysql_error()); \n
?>";
// Write dbconnect.php file
$file = fopen("../includes/dbconnect.php", "w");
fwrite($file, $config);
fclose($file);
echo "<p>MySQL config file was created successfully!</p>";
// Create SimpleNews Tables
include("sql_tables.php");
echo "<p>SimpleNews database tables were created successfully!</p>";
echo "
<p class='error'>At this point, SimpleNews is installed but before you can use it we need to create a user account to log in with. Click the button below to continue.</p>
<form action='./index.php?step=3' method='post' name='next_button'>
<table class='form_table'>
<tr>
<td align='right'><input type='submit' name='next' value='Next Step >>'></td>
</tr>
</table>
</form>";
} else {
echo "
<p>Now we need to setup the database that SimpleNews will use.</p>
<p>If you want to install into an existing database, choose one from the drop-down list below.
Or, if you what to create a new database, enter the name or leave the default name of 'simplenews'.</p>
<form action='./index.php?step=2' method='post' name='step2'>
<input type='hidden' name='username' value='$username'>
<input type='hidden' name='password' value='$password'>
<input type='hidden' name='hostname' value='$hostname'>
<table class='form_table'>
<tr>
<td>Existing Database:</td>
<td>
<select name='dblist'>
<option></option>";
$sql = mysql_connect($hostname,$username,$password);
$db_list = mysql_list_dbs($sql);
while ($row = mysql_fetch_object($db_list)) {
echo"<option value='$row->Database'>$row->Database</option>";
}
echo "
</select>
</td>
</tr>
<tr>
<td>New Database:</td>
<td><input type='text' name='newdb' value='simplenews' size='25'></td>
</tr>
<tr>
<td colspan='2' align='right'><input type='submit' name='submit' value='Next Step >>'></td>
</tr>
</table>
</form>";
}
Warning: mysql_list_dbs() has been disabled for security reasons in /home/a5889267/public_html/simplenews/setup/index.php on line 310
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/a5889267/public_html/simplenews/setup/index.php on line 312