Jump to content

Need a little help with populating a database


Tunes

Recommended Posts

I have created a Table in mysql named creating_members and i would like to populate it is this code correct

<?php
$link = mysql_connect('localhost', 'root', 'tunes');
if (!$link) {
  die('Could not connect: ' . mysql_error());

}

// make TMP the current db
$db_selected = mysql_select_db('TMP', $link);
if (!$db_selected) {
  die ('Can\'t use TMP Database : ' . mysql_error());

}
else{
      print("Connection Successful to TMP database");
}

//add the new information into the database
$query="INSERT INTO creating_members (first_name,last_name,email_address,country_state,comments) VALUES
('$_POST[first_name]','$_POST[last_name]','$_POST[email_address]','$_POST[country_state]','$_POST[comments]')";
if(!mysql_db_query($dbname,$query,$link_id)) die(mysql_error());
echo " success indatabase entry.";


echo "<br />";
echo "<a href=\"form_page.php\">Click here to return to the form page.</a>";
?>


Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.