Jump to content

Luke Warm

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

About Luke Warm

  • Birthday 05/19/1950

Profile Information

  • Gender
    Male
  • Location
    NC

Luke Warm's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Now I'm getting the first two textboxes (still in the last table) Sorry, I probably messed up somewhere. Here's what I have now: <?php session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; $table = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); include("includes/header.html"); ?> <div id="container"> <div id="header"> <?php include("includes/title.php"); ?> </div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="connect_db.php"><img src="images/server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="images/databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="images/server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="images/drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="images/status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="images/server_ico.png" align="left" />Add Fields</a></p> <p><a href="delete_table.php"><img src="images/status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="images/tables_ico.png" align="left" />View Tables</a></p> <p class="active"><a href="view_data.php"><img src="images/user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="dbkiss_front.php"><img src="images/dbkiss_ico.png" align="left" />Database Browser</a></p> <p><a href="connect_info.php"><img src="images/health_ico.png" align="left" />Server Info</a></p> <p><a href="error_log.php"><img src="images/logs_ico.png" align="left" />Server Log</a></p> <p><a href="backup.php"><img src="images/backup_ico.png" align="left" />Backup</a></p> <p><a href="bug_report.php"><img src="images/bugs-icon.png" align="left" />Bug Reports</a></p> <p><a href="logged_out.php" onclick="logOut();"><img src="images/server_logout_ico.png" align="left" />Logout</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="images/controls.png" /></a></div> <div id="main"> <div id="content"> <?php mysql_select_db($database); if(empty($database)) { echo "<p>You must be connected to a database in order to view any table data.</p>"; }else{ $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); $table = array(); while ($row = mysql_fetch_row($result)) { $table[] = $row[0]; } if (count($table) == 0) { echo "<p>The database '" . $database . "' contains no tables.</p>\n"; } else { foreach($table AS $aTable) { echo "<p style='text-align:left;float:left;width:100%;margin-top:15px;'>Table: <font color='green'>$aTable</font>"; // sending query $result = mysql_query("SELECT * FROM {$aTable}"); if (!$result) { die("Query to show fields from table failed"); } } $fields_num = mysql_num_fields($result); echo "<form action='updateinfo.php' method='post'><table border='0' style='text-align:left;width:100%;'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td style='text-align:left;padding:3px;font-size:11px;color:green;'>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows foreach($table AS $aTable) { $result = mysql_query("SELECT * FROM {$aTable}"); echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable //foreach($row as $cell) echo "<td style='text-align:left;padding:3px;font-size:12px;border:1px solid #888;background:#fff;clear:both;float:left;'><input type='text' name='fieldName' value='".$var['fieldName']."' /></td>"; echo "</tr>\n"; } mysql_free_result($result); echo "</table>"; //++$i; ?> <input type="submit" value=" Submit changes " /> <input type="button" value=" Cancel " onclick="window.location='view_data.php'" /> </form> <?php } } include("includes/footer.php"); ?>
  2. I am getting some results on the "edit" page, however, only the last table's data is appearing in the text boxes. Here's the code for my edit page: <?php session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; $table = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); include("includes/header.html"); ?> <div id="container"> <div id="header"> <?php include("includes/title.php"); ?> </div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="connect_db.php"><img src="images/server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="images/databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="images/server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="images/drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="images/status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="images/server_ico.png" align="left" />Add Fields</a></p> <p><a href="delete_table.php"><img src="images/status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="images/tables_ico.png" align="left" />View Tables</a></p> <p class="active"><a href="view_data.php"><img src="images/user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="dbkiss_front.php"><img src="images/dbkiss_ico.png" align="left" />Database Browser</a></p> <p><a href="connect_info.php"><img src="images/health_ico.png" align="left" />Server Info</a></p> <p><a href="error_log.php"><img src="images/logs_ico.png" align="left" />Server Log</a></p> <p><a href="backup.php"><img src="images/backup_ico.png" align="left" />Backup</a></p> <p><a href="bug_report.php"><img src="images/bugs-icon.png" align="left" />Bug Reports</a></p> <p><a href="logged_out.php" onclick="logOut();"><img src="images/server_logout_ico.png" align="left" />Logout</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="images/controls.png" /></a></div> <div id="main"> <div id="content"> <?php mysql_select_db($database); if(empty($database)) { echo "<p>You must be connected to a database in order to view any table data.</p>"; }else{ $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); $table = array(); while ($row = mysql_fetch_row($result)) { $table[] = $row[0]; } if (count($table) == 0) { echo "<p>The database '" . $database . "' contains no tables.</p>\n"; } else { foreach($table AS $aTable) { echo "<p style='text-align:left;float:left;width:100%;margin-top:15px;'>Table: <font color='green'>$aTable</font>"; if (!mysql_connect($hostname, $user, $passwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$aTable}"); if (!$result) { die("Query to show fields from table failed"); } } $fields_num = mysql_num_fields($result); echo "<form action='updateinfo.php' method='post'><table border='0' style='text-align:left;width:100%;'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td style='text-align:left;padding:3px;font-size:11px;color:green;'>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td style='text-align:left;padding:3px;font-size:12px;border:1px solid #888;background:#fff;clear:both;float:left;'><input type='text' value='{$cell}' /></td>"; echo "</tr>\n"; } mysql_free_result($result); echo "</table>"; //++$i; ?> <input type="submit" value=" Submit changes " /> <input type="button" value=" Cancel " onclick="window.location='view_data.php'" /> </form> <?php } } include("includes/footer.php"); ?> The session variable are at the top of the page. I'm using a mysql_fetch_row array to gather the data. Is there a better way to do this?
  3. Thanks for the replies guys. I understand how to insert the edited data. I just don't know how to assign the session variables like $database or $table, etc. to pull the information from the database to the form in order to edit it. I'm using an array to read the table data. Just not sure how to pull individual fields into a form for editing.
  4. Gang, I'm trying to create a form that allows me to edit table data within a MySQL database. I've been able to display the data, no problem. I want to be able to edit the fields in the database tables but have had no luck. I'm using session variables to connect and gather the information I need. Here's the code for collecting the table data: <?php mysql_select_db($database); if(empty($database)) { echo "<p>You must be connected to a database in order to view any table data.</p>"; }else{ // Show table data start $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); $table = array(); while ($row = mysql_fetch_row($result)) { $table[] = $row[0]; } if (count($table) == 0) { echo "<p>The database '" . $database . "' contains no tables.</p>\n"; } else { foreach($table AS $aTable) { echo "<p style='text-align:left;float:left;width:100%;margin-top:15px;'>Table: <font color='green'>$aTable</font>"; if (!mysql_connect($hostname, $user, $passwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$aTable}"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<div style='text-align:left;width:100%;'><table border='0'><tr><td></td>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td style='text-align:left;padding:3px;font-size:11px;color:green;'>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr><td style='text-align:center;padding:3px;font-size:10px;border:1px solid #888;background:#fff;'><a href='edit_data.php?=$row[0]' style='color:red;text-decoration:none;'>edit</a></td>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td style='text-align:left;padding:3px;font-size:10px;border:1px solid #888;background:#fff;clear:both;float:left;'>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); echo "</table></div>"; } } } //end show table data include("includes/footer.php"); ?> I'm not sure how to create a form using the session variables in order to be able to edit the correct information since I want to edit numerous databases. Any help would be great! Thanks
  5. I have an application I've written that allows me to create, drop databases, add tables, fields,etc. I want to be able to view the error.log in a textarea (or whatever) within the application to keep track of Apache.
  6. I do. So far I've tried: <?php include('includes/error.log'); ?> Nothing.
  7. Hey gang, Is there any way to view the apache error.log file in PHP?
  8. I get the following message: DROP TABLE smithereensDeletion of table smithereens failed! -- No database selected HOWEVER... This works! $temp = $_POST['temp']; $sql = "DROP TABLE $temp"; mysql_select_db( $database ); $retval = mysql_query( $sql ); if(!$retval) { die('Could not delete table: ' . mysql_error()); } echo "Table $temp deleted successfully\n"; I appreciate your help. Thanks.
  9. I placed the entire page code in my original post. Here it is again with your code included: <?php include("includes/header.html"); session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; //$tblname = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p class="active"><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="user_admin_ico.png" align="left" />View Tables</a></p> <p><a href="view_data.php"><img src="user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Log</a></p> <p><a href="bug_report.php"><img src="bugs-icon.png" align="left" />Bug Reports</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"><br/> <?php $temp = $_POST['temp']; $query = "DROP TABLE ".$temp; echo $query; mysql_query($query) or die ('Deletion of table '$temp' failed! -- '.mysql_error()); echo "<h1 style='color:green;'>Table $temp deleted</h1>"; include("includes/footer.html"); ?>
  10. I did add the ";" to the echo line and error reporting is definitely on and displaying. I'm on a Linux machine FYI.
  11. I get nothing. deletetable.php won't even load.
  12. Hi, I'm trying to drop a table form a database using the table name as a variable. This variable is set within a session. I am using a form where you input the table name, then the DROP TABLE procedure is executed in the next page. I know that the variable gets passed because it prints the table name variable out when I "echo". The execution is simple (code found in deletetable.php) $temp = $_POST['temp']; $query = "DROP TABLE $temp"; if(mysql_query($query)){ echo "<h1 style='color:green;'>Table $temp deleted</h1>";} else{ echo "<h1 style='color:red;'>Deletion of table '$temp' failed!</h1>";} Here's my code for the two pages: delete_table.php <?php include("includes/header.html"); session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; $tblname = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); /*if(! $conn ) { die('Could not connect: ' . mysql_error()); }*/ ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p class="active"><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="user_admin_ico.png" align="left" />View Tables</a></p> <p><a href="view_data.php"><img src="user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Log</a></p> <p><a href="bug_report.php"><img src="bugs-icon.png" align="left" />Bug Reports</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"> <!--<h1>Delete Database Table</h1>--> <?php if(empty($database)) { echo "<p>You must be connected to a database in order to delete a table.</p>"; }else{ //echo 'Connected successfully to \''.$database.'\''; // Check tables $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { echo "<p style='text-align:left;padding-left:24px;'>Available tables:</p>\n"; echo "<pre style='text-align:left;padding-left:24px;font-size:1.2em;'>\n"; while ($row = mysql_fetch_row($result)) { echo "{$row[0]}\n"; } echo "</pre>\n"; } ?> <form action="deletetable.php" method="post"> Enter table you'd like to delete from '<?php echo $database; ?>' database: <input name="temp" type="text" /><br/> <input name="Submit" type="submit" value=" Delete Table " /> <input type='button' value=' Cancel ' onclick="javascript:window.location='connect_db.php';"></p> </form> <?php } include("includes/footer.html"); ?> Executing file deletetable.php: <?php include("includes/header.html"); session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; //$tblname = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p class="active"><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="user_admin_ico.png" align="left" />View Tables</a></p> <p><a href="view_data.php"><img src="user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Log</a></p> <p><a href="bug_report.php"><img src="bugs-icon.png" align="left" />Bug Reports</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"> <?php $temp = $_POST['temp']; $query = "DROP TABLE $temp"; if(mysql_query($query)){ echo "<h1 style='color:green;'>Table $temp deleted</h1>";} else{ echo "<h1 style='color:red;'>Deletion of table '$temp' failed!</h1>";} include("includes/footer.html"); ?> Your help is greatly appreciated!!
  13. Running the loops is actually better. Rather than trying to run a query each time, looping to show them all works fine. I appreciate the help. Thanks, Keith
  14. Here's the entire page code: <? include("includes/header.html"); session_start(); $_SESSION['hostname'] = $_POST['hostname']; $_SESSION['user'] = $_POST['user']; $_SESSION['passwd'] = $_POST['passwd']; $_SESSION['database'] = $_POST['database']; $_SESSION['table'] = $_POST['table']; ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php if(!$_SESSION['passwd'] && !$_SESSION['database'] && !$_SESSION['table']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."<br/>"; if(!$_SESSION['database']){ echo "</font>"; }else{ echo "Database: ".$_SESSION['database']."</font>"; } } ?> </div> <div id="nav"> <p class="active"><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Connect</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Logs</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"> <?php $action = htmlspecialchars($_GET['action'], ENT_QUOTES); ?> <?php if (!$action) { ?> <h1>MySQL Connection</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=test" id="create_db" method="post"> <table cellpadding="2"> <tr> <td>Hostname:</td> <td><input type="text" name="hostname" id="hostname" value="localhost" size="20" tabindex="1" /></td> <td></td> </tr> <tr> <td>Username:</td> <td><input type="text" name="user" id="user" value="" size="20" tabindex="2" /></td> <td></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="passwd" id="passwd" value="" size="20" tabindex="3" /></td> <td></td> </tr> <tr> <td>Database:</td> <td><input type="text" name="database" id="database" value="" size="20" tabindex="4" /></td> <td style="text-align:left;">(optional)</td> </tr> <tr> <td colspan="3" style="text-align:center;"><input type="submit" id="submit" value=" Connect " tabindex="5" /> <input type="reset" value=" Clear " name="reset"></td> </tr> </table> </form> <?php } ?> <?php if ($action == "test") { $hostname = trim($_POST['hostname']); $user = trim($_POST['user']); $passwd = trim($_POST['passwd']); $database = trim($_POST['database']); $table = trim($_POST['table']); $link = mysql_connect("$hostname", "$user", "$passwd"); if (!$link) { echo "<h1>Could not connect to the server '" . $hostname . "'</h1>\n"; echo mysql_error(); echo "<p align='center'><input type='button' value=' Back ' onclick='javascript:history.back();'></p>"; }else{ //echo "<h1>Successfully connected to the server '" . $hostname . "'</h1>\n"; printf("MySQL client info: %s\n", mysql_get_client_info()); // printf("MySQL host info: %s\n", mysql_get_host_info()); } if ($link && !$database) { echo "<p>No database name was given.</p><p style='text-align:left;padding-left:24px;width:80%;'>Available databases:</p>\n"; $db_list = mysql_list_dbs($link); echo "<pre style='text-align:left;padding-left:24px;font-size:1em;line-height:12px;'>\n"; while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } echo "</pre>\n"; } if ($database) { $dbcheck = mysql_select_db("$database"); if (!$dbcheck) { echo "<p align='center'>".mysql_error()."</p>"; echo " <input type='button' value=' Cancel ' onclick='javascript:history.back();'></p>"; }else{ echo "<form name='frm1' method='get' action=''><p style='text-align:center;width:37%;float:left;margin-top:0px;'>Available tables: "; echo "<select name='tables'>"; $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); while ($row = mysql_fetch_row($result)) { echo "<option value='{$row[0]}' selected>{$row[0]}</option>\n"; $table = $row[0]; } echo "</select></p>"; echo "<p style='text-align:left;padding-left:24px;float:right;width:60%;margin-top:-15px;border:1px solid #d6d6d6;'>Table Fields: $table"; echo "<pre style='text-align:left;padding-left:24px;font-size:1.2em;width:50%;float:right;'>"; $result = mysql_query("SHOW COLUMNS FROM $table"); if (!$result) { echo "<p>The database '" . $database . "' contains no tables.</p>\n"; exit; } if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { print_r ($row); } echo "\n</pre></form>"; } else { //echo mysql_error(); echo '<p style=\'text-align:center;margin-bottom:-100px;\'><input type="button" value=" Create New Table " onclick="javascript:window.open(\'create_table.php\',\'_self\');">'; echo " <input type='button' value=' Cancel ' onclick='javascript:history.back();'></p>"; } } } } include("includes/footer.html"); ?> Hope this helps. Thank you.
  15. The form gets submitted to itself " <?php echo $_SERVER['PHP_SELF']; ?> " and the method is POST.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.