derrick1123 Posted March 16, 2008 Share Posted March 16, 2008 <?php $db_host = $_POST['db_host']; $db_user = $_POST['db_user']; $db_password = $_POST['db_pass']; $db_name = $_POST['db_name']; //database info $db = mysql_connect($db_host,$db_user,$db_password) or die("Could not connect."); if(!$db) die("no db"); if(!mysql_select_db($db_name,$db)) die("No database selected."); //end database info ?> I have the other file that inserts the data...but I don't know to keep the information there. How is this possible? Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/ Share on other sites More sharing options...
trq Posted March 16, 2008 Share Posted March 16, 2008 Sorry, your question is? Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493594 Share on other sites More sharing options...
derrick1123 Posted March 16, 2008 Author Share Posted March 16, 2008 Like how do I write the database information to the db_settings.php. (which is what that file above is) Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493595 Share on other sites More sharing options...
trq Posted March 16, 2008 Share Posted March 16, 2008 Nope, your going to need to try harder. Describe your actual problem, were not mind readers. Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493602 Share on other sites More sharing options...
derrick1123 Posted March 16, 2008 Author Share Posted March 16, 2008 I have a form that lets the owners of the script enter in the information to the db_settings.php. Right now I have it only were it tempraily writes it to db_settings.php. I need to find out how to perminatly write the settings. Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493605 Share on other sites More sharing options...
trq Posted March 16, 2008 Share Posted March 16, 2008 Theres a link in my signiture to a free book that might be a good place to start. Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493608 Share on other sites More sharing options...
trq Posted March 16, 2008 Share Posted March 16, 2008 A simple example.... <?php // connect to db. if (isset($_POST['submit'])) { $data = mysql_real_escape_string($_POST['data']); $sql = "INSERT INTO tbl (data) VALUES ('$data')"; if (mysql_query($sql)) { if (mysql_affected_rows()) { echo "Data added to the database"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/96439-form-for-inserting-db-info/#findComment-493611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.